Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #589501

    In the sidebar widgets, we have it set up to display the items within the same category as the main item on the page. Is there a way to prevent that current page/item from appearing in list of items in the sidebar widget?

    I searched the forums for an answer using various keyword combinations but couldn’t find anything specifically relevant…

    This happens with Portfolio items, but also more generally…

    Thanks!

    #590540

    Hi,

    Can you please create us a WordPress administrator account? post it here as a private reply.

    Regards,
    Josue

    #591254

    I thought I had replied already here…

    We’re also having a problem editing any content inside a 4/5 column element within the Advanced Layout Editor on page indicated below in private

    Thanks!!

    • This reply was modified 8 years, 9 months ago by tcowin.
    #592574

    Hi!

    We added this code in the functions.php file:

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

    Regards,
    Ismael

    #592826

    Thanks Ismael – if I wanted to make sure that the Posts behave the same way, I’m assuming I’d just modify the if statement like so: (?)

    if (is_singular('portfolio') || is_singular('post'))

    ?

    #593247

    Hey!

    Yes, I think that will do it. Please use this code instead:

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

    We added the is_admin conditional so that it won’t affect the dashboard.

    Best regards,
    Ismael

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.