- This topic has 5 replies, 2 voices, and was last updated 2 years, 5 months ago by
Ying.
-
AuthorPosts
-
April 8, 2023 at 10:18 pm #2602650
Henry
I assign full-page or two-column layouts based on the Elements > Layout option which works great, i.e. you just assign the page type, etc and it assigns the correct layout.
However, I have a Custom Taxonomy that does NOT appear in the “Display Rules” dropdowns…
So, I am left with customizing the PHP Template; – so – my question is – how can I make the PHP Template full width or contained as ONE column just using PHP.
Hope that’s clear!
Thanks!
April 9, 2023 at 11:38 am #2603271Ying
StaffCustomer SupportHi Henry,
However, I have a Custom Taxonomy that does NOT appear in the “Display Rules” dropdowns…
Custom taxonomies should’ve shown in the display rule.
Do you only have more than one custom taxonomy? If so, are other custom taxonomies showing up in the display rule?
If you only have one custom taxonomy, can you attach the settings of the custom taxonomy?
Let me know!
April 11, 2023 at 7:16 am #2605592Henry
Thanks for helping…
Hmmm..I am using a popular WP Plugin called CPT UI for the Custom Post Type/Taxonomies…now, if I associate my Custom Taxonomy with the WP Core Pages (for example) then yes, it does appear in the GeneratePress elements dropdown. HOWEVER, the dropdown lists the posts one by one and I can’t select “ALL”.
TBH, I think a faster solution is just to modify the PHP template itself….
Is there anything I can place in the header or body tag that can force the template to be one column?
Thanks!
April 11, 2023 at 10:28 am #2606023Ying
StaffCustomer SupportIn that case, try the following steps:
1. create a layout element for the custom taxonomy, do NOT assign any location, publish it.
2. Add this PHP code, change 1000 to the actual element id (you can find it in the URL of the element editor), change
my_cpt
to the post type you want to apply to, changemy_custom_tax
to the actual custom taxonomy slug.add_filter( 'generate_element_display', function( $display, $element_id ) { global $post; // Check if the current post is of the custom post type "my_cpt" if (1000 === $element_id && 'my_cpt' === get_post_type() ) { // Check if the current post has any term assigned to the custom taxonomy "my_custom_tax" if ( has_term( '', 'my_custom_tax' ) ) { $display = true; } else { $display = false; } } else { $display = false; } return $display; }, 10, 2 );
Adding PHP: https://docs.generatepress.com/article/adding-php/
April 12, 2023 at 2:53 am #2606827Henry
Good job!
It worked 🙂
Thanks
April 12, 2023 at 10:30 am #2607594Ying
StaffCustomer SupportYou are welcome 🙂
-
AuthorPosts
- You must be logged in to reply to this topic.