Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #558578

    Is there a way to prevent the current page or post from showing up in a blog post or magazine? For instance, I create a new page called “new science” with a post tag of “science”. On that page, along with other content, I include a blog post pulling in all other posts or pages with the tag “science”. But I don’t want the “new science” page to appear in the blog post because that would be redundant. The “new science” page still needs the “science” tag so it can be pulled into blog posts in other sections of the site. Is there any way to add code or settings to the blog post element so that it never includes the page or post in which the blog post appears?
    Thanks!
    Nancy

    #558641

    Hi MBARI-WP!

    So you have two tags, “science” and “new science”, and they are both being pulled in? Are you sure you just have “science” selected? It should not be pulling in both.

    Send us a WordPress login and a link to the page so we can take a look.

    Cheers!
    Elliott

    #558729

    Hi Elliott,
    No, I don’t have two tags, I only have the one tag “science”. However, the “new science” page is tagged with “science” because in other parts of the site I’d want it included among all science content. So when I add a blog post on the “new science” page, and pull in with a custom taxonomy of post tags “science”, that page itself shows up in the blog posts. I hope that makes it clearer.
    Unfortunately, our site is behind a firewall while we are in development. I thought this might be a common challenge for developers so there might be a solution available. If you need to get to our site, I’ll have to re-contact you in a couple of weeks when our site is public.
    Thanks,
    Nancy

    #558751

    Hi!

    So your adding the “science” tag to the page named “new science”? WordPress does not let you add tags to pages. Do you mean you have a post named “new science”?

    It sounds like your using the blog posts element on a post itself with the advanced layout editor and your wanting to exclude that post from the query. Maybe something like this would work.

    add_filter('avia_blog_post_query', 'enfold_customization_query_custom');
    function enfold_customization_query_custom( $query ) {
    global $wp_query;
    if ( is_single() ) {
    $query['post__not_in'] = array($post->ID);
    return $query;
    }
    }

    Try adding it to your child theme functions.php file.

    Best regards,
    Elliott

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