Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #739010

    Hello,

    Just wondering if its possible to exclude the post you are currently on from the recent post listing in the sidebar? I found this, http://wordpress.stackexchange.com/questions/28792/exclude-current-post-from-recent-posts-loop , but have no idea how to apply this. URL to a single post is in the private content, let me know if you need anything else!

    Thank you!
    Chris

    #740483

    Hi ind-image!

    Thank you for using Enfold.

    Please try this in the functions.php file:

    add_action('pre_get_posts', 'ava_exclude_widget_post');
    function ava_exclude_widget_post($query) {
    	if (!is_admin() && is_singular('post')) {
        		$exclude = avia_get_the_ID();
    		$query->set( 'post__not_in', array($exclude) );
    	}
    }

    Best regards,
    Ismael

    #740827

    Awesome! Works like a charm! Thanks Ismael! This ticket can be closed.

Viewing 3 posts - 1 through 3 (of 3 total)
  • The topic ‘Exclude Current Post from Recent Posts in Sidebar’ is closed to new replies.