Ready to get started?Download WordPress


Twenty Fourteen
[resolved] Don't exclude featured posts from front page query (5 posts)

  1. Toeps
    Posted 3 months ago #


    I'm trying to "hack" this for days now... We have the new WordPress 3.8 running ( on http://www.fashionmilk.com ) and I would like the featured posts in the grid to be shown on the front page as normal posts as well.

    I found that the posts are excluded in a .php-file at inc/featured-posts.php
    So I even deleted that whole piece of code (the piece below "Exclude featured posts from the home page blog query"). I know that's not the right way to do it, but to my surprise even without this code, the posts aren't showing up! I'm confused... Is there some kind of cache? Am I missing a piece of code?

    Wouldn't it be easier to make users choose, just as we can choose the featured tag to be visible or not? Just another option like: "Show/hide posts in the grid/slider on the front page" I know the posts are basically doubled then, but our readers might miss out on posts that are only visible in the featured area.

    Can anyone tell me how I can do this for now? Tnx!

  2. Jesin A
    Posted 3 months ago #

    I see that you have copied the featured-posts.php file from the parent theme to your child theme and have edited it.

    This isn't working because the parent theme is programmed to "include" this file only from its own directory. The last few lines of functions.php

    if ( ! class_exists( 'Featured_Content' ) && 'plugins.php' !== $GLOBALS['pagenow'] ) {
    	require get_template_directory() . '/inc/featured-content.php';

    The get_template_directory() function returns the absolute path of the parent theme.

    Now to solve your problem edit the wp-content/themes/twentyfourteen-child/functions.php file and place the following code.

    add_action( 'init', 'show_featured_content_on_home', 31 );
    function show_featured_content_on_home()
    remove_action( 'pre_get_posts', array( 'Featured_Content', 'pre_get_posts' ) );
  3. Ben Meredith
    Posted 3 months ago #

    So, you are looking to put posts in the grid and then immediately below the grid as well?

    Off the top of my head, you'd want to disable the grid in the settings, and then figure out a way (perhaps a plugin?) to add a featured box at the top of the page with the most recent posts featured.

    The short answer is that you are trying to modify what is called the "loop" which is a core piece of how WordPress delivers content, and you don't want to do that. Using a plugin will give you much better results.

    Let me know if that doesn't make sense!

  4. Toeps
    Posted 3 months ago #

    OMG Jesin A, THANKS SO MUCH! It works!

    And yes, Ben, I wans to put posts in the grid and below ;)
    Our readers are used to all the posts on the home page blog, the grid is just an extra thing. We used to have a slider before that worked just like that. I don't want to disable the grid, I just wanted to disable the function that then hides the posts from the "normal" site query :)

  5. Jesin A
    Posted 3 months ago #

    You're welcome. Great to hear that!!!


You must log in to post.

About this Theme

About this Topic