Only want to show 3 featured images in grid
-
Hi-
I’d like to only show 3 featured images in the grid as opposed to the 6 that come with twentyfourteen.
I have a child theme to accomodate the changes.
Thanks!
-
Hi Byjeteast,
You have quite a few threads going.
Try taking off the tag Featured from the posts you don’t like to have displayed in the grid.
Alternatively, you need to create a functions.php file inside your child theme. Add this code:
// Add support for featured content. function twentyfourteen_child_setup () { // This will remove support for featured content as set up in parent remove_theme_support( 'featured-content' ); //add support for featured content with 3 posts add_theme_support( 'featured-content', array( 'featured_content_filter' => 'twentyfourteen_get_featured_posts', 'max_posts' => 3, ) ); } add_action( 'after_setup_theme', 'twentyfourteen_child_setup', 11);
You might have to toggle between grid and slider in the customizer to allow the new default to stick.
I’ve actually tried out this in my local WP install and it works. Let me know if it’s working for you ??
Uh oh- that definitely didn’t work for me. I copied the functions.php file in to my child theme, deleted everything out of it, and added the code you gave me above. I tried toggling between the grid and the slider and, not only did it not go to 3 images, this happened- ooops!
https://postimg.org/image/aw1qnbda5/
I’ve left it up on the site for now too https://www.byjeteast.com
What did I do wrong? Thank you a million times over for your help!
I can see your site is still showing the 6 default slots for featured posts.
I assume your functions.php file in the child theme contains only the code I posted above (I also assume you’ve added it below an opening php tag (
<?php
). I also assume you’ve either chosen a tag, e.g., featured in the Customizer panel, to select your featured posts, or you’ve designated them as sticky posts.Assuming all of the above, one last thing you could try out is this.
Keep you child theme activated. Then access functions.php file in the parent theme and open it inside a code editor. Find this function:
function twentyfourteen_setup() {
Inside this function, find the theme support for featured content (about line 108). It looks like this:
// Add support for featured content. add_theme_support( 'featured-content', array( 'featured_content_filter' => 'twentyfourteen_get_featured_posts', 'max_posts' => 6, ) );
Now change the value of the max_posts array item from 6 to 3. Save and refresh your browser (you’re still using your child theme as the active theme) to see if the number of featured posts has changed from 6 to 3. If it has, go back to functions.php in the parent theme and reset the value of max_posts to 6. Save your files, go back to the browser and refresh the page. Now, if nothing else interferes, your page should show 3 posts.
I hope this works, let me know ??
No dice still (and sorry for the long delay)!
This was everything that was in my child theme functions.php file and it was basically completely breaking the site
<?php // Add support for featured content. function twentyfourteen_child_setup () { ? // This will remove support for featured content as set up in parent ? remove_theme_support( 'featured-content' ); ? //add support for featured content with 3 posts ? add_theme_support( 'featured-content', array( ? ? 'featured_content_filter' => 'twentyfourteen_get_featured_posts', ? ? 'max_posts' => 3, ? ?) ); } add_action( 'after_setup_theme', 'twentyfourteen_child_setup', 11);
I tried going in and changing the parent theme like you said, but the site remained “broken”.
Even if I just copy the whole functions.php file into my child theme without making any changes, it completely breaks the site
“Fatal error: Cannot redeclare twentyfourteen_content_width() (previously declared in /home/jesalv9/byjeteast.com/wp-content/themes/twentyfourteen-child/functions.php:126) in /home/jesalv9/byjeteast.com/wp-content/themes/twentyfourteen/functions.php on line 129”
Any idea? It seems like just copying the exact same functions.php file shouldn’t cause the whole thing to bug out, but what do i know. Thanks!
Hi Byjeteast,
I actually tested this solution in my local WP install and it worked. To understand a bit better what’s going on I need to replicate the problem. Could you post a link where I could download your child theme? (you could use a service like Google drive or something similar).
Thanks.
Hey Maria-
Google drive was acting up, but my child theme isn’t particularly large so here it is (without any of the code we’ve discussed in this thread, since I’ve removed it all since it kept breaking everything).
/* Theme Name: byJetEast Template: twentyfourteen */ @import url('../twentyfourteen/style.css'); /*remove category titles from featured images*/ .featured-content .entry-meta { display: none; }? /*increase title size*/ .site-title { float: left; font-size: 45px; font-weight: 700; line-height: 48px; margin: 0; } /*move title up and decrease size of title*/ .entry-title { font-size: 28px; margin: -40px 0 12px; } /*remove archive content title*/ .archive-header {display:none} /*remove white space from category header*/ .content-area, .content-sidebar { padding-top: 0px;} /*reduce space between widgets*/ .primary-sidebar .widget .widget-title {margin-bottom:2px;} /*increase size of tagline*/ .site-description { font-size: 15px; } /*remove title and white space in archive headers*/ .archive-title, .page-title {display:none} .archive-header, .page-header {display:none}
Thank you SO MUCH!
I’ll have a look into it and report back to you.
Hi there, it worked perfectly on my end. Here’s the link to the demo child theme on Google Drive:
https://drive.google.com/folderview?id=0BwTOtdtcr1WaMXR4XzBvaFBNQlU&usp=sharing
To make it work follow these steps sequentially (they got things working for me):
1. install the child theme and view the site. If you still see more than three photos …
2. Activate Twenty Fourteen. Open functions.php in Twenty Fourteen and change 6 to 3 in the add_theme_support for featured content function. Save and check the site. Now your page should display 3 photos.
3. Activate your child theme and visit the site. It should still display three photos.
4. Change back the parent theme‘s add_theme_support function for featured content in functions.php to its original value of 6 and save it.
5. Now view your site (the active theme should be your child theme at this time) and make sure you see three photos.
If this is not the case, I can’t replicate the issue and perhaps there could be something else that interferes with the code on your end. In any case you might want to show me what the page looks like at the end of the operation, so I understand better what you mean when you say that the site is broken.
I know it looks like a long process, but that’s what debugging code is all about ??
IT WORKED!!! wahooo!!!! thank you SOOO much! RESOLVED!
wait! ugh! it just went back to 6 for no reason?! this is maddening haha
No idea what that was about…I got it to go back to 3, so worst case scenario I’ll just go through the steps again without changing the value in the parent theme back and remember to change it if i update wordpress. Thanks again!
No problem, it should stick though.
- The topic ‘Only want to show 3 featured images in grid’ is closed to new replies.