Forums

Can I prevent certain posts from appearing on one particular page? (2 posts)

  1. oneninetyseven
    Member
    Posted 1 year ago #

    Hi everyone,

    I know that there are plugins which prevent posts from appearing on the home page, etc.

    However, I need something more than that.

    I'm working on a site which is made up of pages. One of the pages is the blog. I have this blog page designated in the Reading settings as the page on which posts appear.

    However - the theme I'm using included a number of pre-populated posts (I can change the content) which can appear in an upper menu (a narrow bar immediately above the site header). The problem is that if I set these particular posts (which actually act as menus) to appear in the upper menu, they also appear in the page I've designated as a blog.

    That's a problem, because they (the upper menu posts) are not blog posts; they appear in the upper menu as titles which are links to the posts themselves.

    Just the way this theme is set up.

    Is there a way to prevent just these "menu posts" from appearing in the page I've designated as a blog while still allowing them to appear in the upper navigation menu of the site?

    Can I create some sort of category to which I can assign them that excludes them from the page I've designated as the blog?

    Really appreciate your help! The site in question is HERE.

    Thanks!

  2. Digital Raindrops
    Member
    Posted 1 year ago #

    Just a suggestion add them to a category and exclude that category in index.php with wp_query() then reset the query.

    Example Twenty Ten theme two code blocks:

    get_header(); ?>
    
    	<div id="container">
    		<div id="content" role="main">
    
    		<?php
    		// Code to remove homepage posts
    		$query = new WP_Query( 'cat=-12' );
    		?>
    
    		<?php
    		/* Run the loop to output the posts.
    		 * If you want to overload this in a child theme then include a file
    		 * called loop-index.php and that will be used instead.
    		 */
    		 get_template_part( 'loop', 'index' );
    		?>
    
    		<?php
    		// Code to reset the query
    		wp_reset_query();
    		?>
    
    		</div><!-- #content -->
    	</div><!-- #container -->
    
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>

    HTH

    David

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.