Hey. I have a bit of code in the functions.php of my child theme which shows the Author at the bottom of every post. This works, and yet I’d like to exclude a few select posts from that. How could I override that function for specific posts?
Hello There,
You can add a condition within your function so that you can exclude the single posts. For example:
function the_function_name(){
if ( ! is_single(array(1,2,3)) ) {
// display author action
}
}
where in the 1,2,3 are the IDs of the posts. To know where you can get the post IDs so that you can exclude it, please check it here: https://theme.co/apex/forum/t/setup-how-to-locate-post-ids/59
Hope this helps.
Nice. What about removing the Author shortcode showing on an entire category of posts?
Hi Peter,
In this case, you should wrap your code between:
if ( ! in_category(array(1,2,3)) ) {
// display author action
}
where these numbers are the categories IDs, names or slugs. Check this page to know more about the in_category
conditional tag.
Thanks.
This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.