• Good evening smart people! I have reached a wall with something and am hoping you can help me… I am using the ‘Selecta’ theme and it comes with a “Featured Post” widget, to be used in the header, that will put posts marked as “sticky posts” in a slider above the main feed. Awesome. Eggsactly what I need… However, what I designate as sticky, not only shows up in this widget, it also takes the top position by default, in my blog feed. Whenever I add a new post, regardless of the date, it will post in the 6th position, under the first five sticky posts. I don’t want sticky posts to show in the feed at all, just in the slider in the header. I have poured through alot of documentation regarding similar issues but have yet to find anything that works with my situation. I keep seeing stuff about “loops” and “home.php” scripts, but I don’t have any sheets like that in my repository. I read the codex about excluding catagories by ID and tried to exclude the “sticky post” catagory in my “index.php” but it ended up eliminating everything BUT the sticky posts. I’m really lost and so close to getting this blog ready to launch!! Any help would be much appreciated and just for the record, I’m not the best with code, but I’m learning! Thanks guys!

Viewing 3 replies - 1 through 3 (of 3 total)
  • You’ll probably have to go into your template file that handles the blog, probably the index.php file and exclude sticky posts from the query. This page in the codex should get you going: https://codex.www.ads-software.com/Class_Reference/WP_Query#Sticky_Post_Parameters

    Thread Starter jeffrhi

    (@jeffrhi)

    I see the code that your talking about in the WP-Query codex…

    “Don’t Show Sticky Posts – Exclude all sticky posts from the query”
    $query = new WP_Query( array( 'post__not_in' => get_option( 'sticky_posts' ) ) );

    …but I guess I’m not exactly sure where to put it. Here is the “index.php” code I have. Can you tell from this if this is where it would be implemented and if so, how? (sorry for my noobness!)

    <?php get_header(); ?>
            <?php if (function_exists('dynamic_sidebar')) : dynamic_sidebar(2); endif; ?>
    <div id="content">
            <?php if (have_posts()) :
            while (have_posts()) :  the_post(); setup_postdata($post);
            get_template_part("/functions/fetch-list");
              endwhile;
            else :
              ocmx_no_posts();
            endif; ?>
                    <div class="pagination-container">
                    <?php ocmx_pagination("pagination clearfix"); ?>
            </div>
        </div>
        <?php get_sidebar(); ?>
    
    <?php get_footer(); ?>

    Thanks for the reply! I really appreciate it!

    Thread Starter jeffrhi

    (@jeffrhi)

    Wait, should this be used on the “query.php” sheet or the “index.php”?
    It looks like it should be in the “wp-includes/query.php.” but, again, not sure where to input it.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Sticky posts showing in main feed as well as featured post slider’ is closed to new replies.