• The featured content on the front page is awesome and works great with my site. Is this limited to just 6 posts or can this be modified?

    Is it possible to have “many” posts as featured and WP randomly pick the 6 it uses?

Viewing 9 replies - 1 through 9 (of 9 total)
  • Is this limited to just 6 posts or can this be modified?

    You can try changing it from 6 to something else in functions.php:

    add_theme_support( 'featured-content', array(
    		'featured_content_filter' => 'twentyfourteen_get_featured_posts',
    		'max_posts' => 6,
    ) );

    Be sure to create a child theme so your changes won’t be overwritten when you update the theme. Here are some guides in case you haven’t made one before:

    http://codex.wordpress.org/Child_Themes
    http://op111.net/53/
    http://vimeo.com/49770088

    I’ll let my colleague answer about the randomization.

    To have Featured Content show random posts, we would need to add an orderby parameter to the section at line 169 in inc/featured-content.php, so that it looks like this:

    // Query for featured posts.
    $featured = get_posts( array(
    	'numberposts' => $settings['quantity'],
    	'tax_query'   => array(
    		array(
    			'field'    => 'term_id',
    			'taxonomy' => 'post_tag',
    			'terms'    => $tag,
    		),
    	),
    	'orderby'          => 'rand',
    ) );

    Now, as Kathryn mentioned above, the proper way to make these changes is in a child theme. However, the above changes will not currently work if done in a child theme; we’re fixing that up.

    If you want to use the above changes, they’ll need to be done in the Twenty Fourteen theme itself, which means you’ll risk losing those changes when Twenty Fourteen gets updated. If you’re comfortable doing it anyways, you’ll also need to comment out two lines, also in inc/featured-content.php: lines 154 and 190.

    // $featured_ids = get_transient( 'featured_content_ids' );
    // set_transient( 'featured_content_ids', $featured_ids );

    @kathryn: You wrote “try changing it” and I did, but it doesn’t seem to work for me: I still only see only 6 posts although I changed the number to “20”.

    I did it in the original “functions.php” and even commented out the lines Kirk wrote about.

    Is there something else that needs to be changed?

    Thank you both for your help.
    Sascha

    Ah yes, I see; there’s also a hard-coded maximum that needs to be changed for greater than 6 posts (apologies, I was testing with 1-5 posts). Also change line 475 in inc/featured-content.php to match your desired number of posts, and you should be good.

    Hi guys, I have quite a similar need: just 3 random featured content.
    Unfortunately, I tried all your suggestions without any good.
    my blog is http://www.terradimezzo.net/ludoteca

    Any more suggestions?

    Saramund – could you start a separate thread for your question so we can help you more easily one-on-one? Please include a link to the contents of your modified inc/featured-content.php file in one Pastebin and the contents of functions.php in another Pastebin. Thanks.

    Saramund, did you check the customize theme settings? I went back to the overall customization page and it was trying to use the ‘featured’ tag (a tag I had not used). I changed this to a tag I had used and it worked fine. Three posts, randomised by tag.

    Not for me 🙁
    yes, I did change the tag before and also now (just to be sure). No way.
    It keeps on publishing the 3 most recent posts.

    I have create a new post as suggested by Kathrin:
    http://wordpress.org/support/topic/theme-twenty-fourteen-unable-to-randomize-featured-content?replies=1

    By the way, deactivating “Jetpack by WordPress.com” and it now works.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Featured Content: Limited to 6? Possible to randomize?’ is closed to new replies.