Opened 11 years ago
Closed 11 years ago
#26660 closed defect (bug) (fixed)
Twenty Fourteen: Featured Content transients block child themes from overriding the number of FC posts
Reported by: | kwight | Owned by: | |
---|---|---|---|
Milestone: | 3.9 | Priority: | normal |
Severity: | normal | Version: | 3.9 |
Component: | Bundled Theme | Keywords: | has-patch commit fixed-major |
Focuses: | Cc: |
Description
By creating a child theme, we should be able to change the number of Featured Content posts with our own add_theme_support
call and a different max_posts
argument. Somehow transients are getting in the way.
To replicate:
- create and activate a Twenty Fourteen child theme
- define your own
twentyfourteen_setup
function - change
max_posts
to something other than 6 in theadd_theme_support
call - notice 6 FC posts are still returned
- comment out L154 and L190 in the parent theme
inc/featured-content.php
to disable transients - the correct number of posts are now returned
Attachments (2)
Change History (15)
#2
@
11 years ago
The transient is deleted on post_save and delete_post_tag. Something like this would solve the problem in the TwentyFourteen theme.
function twentyfourteen_switch_theme() { delete_transient( 'featured_content_ids' ); } add_action( 'switch_theme', 'twentyfourteen_switch_theme' );
@
11 years ago
looks like we already have a function with that exact name although not sure back-compat is best place for it.
#6
@
11 years ago
Deleting the transient on theme switch indeed solves the issue. We already deleted it on customizer views, so that even if you previewed the theme, the correct amount of posts would show.
There is a second bug though. Since we manually define the quantity parameter to 6, child themes were not able to increase the amount of featured posts by increasing $max_posts
. They also have to manually reset the quantity setting through a filter on get_option( 'featured-content' )
. We should be able to safely remove that parameter since users didn't have a possibility to change them.
#7
follow-up:
↓ 8
@
11 years ago
26660.2.diff works for me. Just noting that every time the max_posts
parameter is changed in the add_theme_support
call, the user will need to visit the Customizer (or switch themes) to delete the previous transient and see the new number of posts.
#8
in reply to:
↑ 7
@
11 years ago
- Keywords needs-testing removed
Replying to kwight:
Just noting that every time the
max_posts
parameter is changed in theadd_theme_support
call, the user will need to visit the Customizer (or switch themes) to delete the previous transient and see the new number of posts.
If someone changes code like that, I don't think purging the cache is too much to ask. Also, since the Customizer is the only place to change FC settings, changes are they will access it sooner rather than later.
I think that this behavior is not linked to a child theme specifically.
If the transient is set once using the original
max_posts
parameter, it will be used to display the featured content. Whether you create a child theme or change the value ofmax_posts
in Twenty Fourteen itself, the transient won't be regenerated.If you clear the transient, a new one is created with the changed parameter and everything works as expected.