Archived topic
Specific display for custom taxonomie
12 replies · Started by Thierry on November 8, 2016
Hello,
I use this plugin : https://wordpress.org/plugins/custom-post-type-ui/
For a specific taxonomies i want display (or not display) the elements (sidebar, read more)
I think make a copy og archives.php but after ? what is the process ?
Thx
You would make a copy and then name it to match the post type: https://developer.wordpress.org/themes/basics/template-hierarchy/#custom-post-types
Great and for customize this page how i can di this ?
You would just take the copied file, rename it and then add your customizations to the code.
Hi, ok but where i can found an exemple for i understand the customisation of this specific file ?
thank you so much
I begin to understand but I need help.
I copy content.php and i create content-news.php for a specific layout, if i want 2 sidebar whow i can code this ?
Sidebar layouts can be altered using a filter: https://generatepress.com/knowledgebase/choosing-sidebar-layouts/#sidebar-filter
So if your custom post type is named "news", you could do something like this:
add_filter( 'generate_sidebar_layout','generate_cpt_sidebar_layout' );
function generate_cpt_sidebar_layout( $layout )
{
// If we are on a woocommerce page, set the sidebar
if ( 'news' == get_post_type() )
return 'both-left';
// Or else, set the regular layout
return $layout;
}
ok Tom, step by step i I advance and now my problem is displaying ACF field in the sidebar for the single page. You think a solution ?
If you want it in a widget, you'll need to make a shortcode with your ACF field.
Might be worth asking them what the best way is.
simply, great :)
thank you Tom, last thing if i want modify a sidebar only with code, it's possible ?
What exactly are you modifying? You can choose to display sidebar using the code I posted above: https://generatepress.com/forums/topic/specific-display-for-custom-taxonomie/#post-245212
Yes i think that's ok, thx Tom :)
You're welcome :)