Tagged: blog posts, display blogs, display posts, hide blogs, hide posts
Hi, I’m using Enfold. I added ‘Blog Posts’ to the bottom of ALL single posts (I call this section “Related Posts”). I’m just showing the last 3 posts. How do I hide the post I’m currently on from this ‘Related Posts” section?
Example: http://www.mycompany/blog/post2/
On this page, the “Related Posts” section should hide Post 2. It should only display Posts 1, 3 and 4.
Hey Celeranttechnologycorp,
Try adding this code to the end of your child theme functions.php file in Appearance ▸ Editor:
add_filter('avia_post_slide_query', 'avf_custom_post_grid_query');
function avf_custom_post_grid_query ( $query ) {
if(is_singular('post')) {
global $post;
$query['post__not_in'] = array($post->ID);
}
return $query;
}
Best regards,
Mike
Hi Mike, Thank you. This worked. I just had to change the variable so it accounts for my custom post type.
if(is_singular(‘post’)) {
to
if(is_singular(‘press’)) {
Hi,
Glad to hear that you have this sorted out, if you have any further questions please create a new thread and we will gladly try to help you. Thank you for using Enfold.
Best regards,
Mike