I have successfully managed, with the help of someone extremely helpful here on stackoverflow, to add a a custom and dynamic description to all the posts used in my website. My issue now is that when opening one of my pages, I do not get the page content but the dynamic description that was intended for posts only.
The code I have added to my functions.php to generate the dynamic descriptions is as follows:
function add_after_post_content($content) {
global $post;
if(!is_feed() && !is_home() && is_singular() && is_main_query()) {
$post_categories = wp_get_post_categories( $post->ID );
$cats = array();
foreach($post_categories as $c){
$cat = get_category( $c );
$cats[] = array( 'name' => $cat->name, 'slug' => $cat->slug );
}
$content = '<h2>About the wallpaper:</h2><br />The <strong>'. $post->post_title . ' wallpaper</strong> is a high quality and high resolution wallpaper that has been posted in the <strong>';
foreach($cats as $c){
$content .= $c['name'];
}
$content .= '</strong> category by <strong>Free Wallpapers</strong> on '. $post->post_date . '.';
}
return $content;
}
add_filter('the_content', 'add_after_post_content');
The issue now is that I am finding on post pages eg. copyright page, that the dynamic content is being used instead of the content set in the wordpress admin.
Copyright Policy and Usage Rights
About the wallpaper:
The Copyright Policy and Usage Rights wallpaper is a high quality and high resolution wallpaper that has been posted in the category by Free Wallpapers on 2014-05-14 20:56:29.
I would like to continue using the dynamic content for my posts, while excluding pages from displaying it. Any help in regards to this matter would be greatly appreciate.
Best Regards