Archived topic
Template of GP in draft posts
4 replies · Started by Mario on February 14, 2017
I have literally more than 2000 posts to be published. However, I would like to change some configurations of these drafts:
- Page header - Logo - Choose Logo (with a specific image obviously)
- Sidebar / Content
My preconfiguration is different from those above mentioned.
How can I make a template with those two changes to be applied on those 2000 posts automatically, instead of modifying them manually one by one?
Hi Mario,
Are there any logic to which of the 2000 posts you would like those two changes to apply to? Like are they a specific category?
If not then I think you would have to do it with the similar way as swapping out logos with php, if statements and page slug.
This post provides some info: https://generatepress.com/forums/topic/how-to-create-different-post-template/
Hi Leo,
Answering your first comment, I would say yes, all those yet unpublished posts present one common category.
I've been checking out the links you posted, but I am a little bit lost...
Ok then you would use the generate_sidebar_layout filter and do something like this:
add_filter( 'generate_sidebar_layout','tu_custom_category_sidebar_layout' );
function tu_custom_category_sidebar_layout( $layout )
{
// If we are on a category, set the sidebar
if ( is_category( 'Whatever' ) )
return 'left-sidebar';
// Or else, set the regular layout
return $layout;
}
https://docs.generatepress.com/article/sidebar-layout/#using-a-function
Adding PHP: https://docs.generatepress.com/article/adding-php/