Site logo

Archived topic

Page hero for custom taxonomy

1 reply · Started by Javier on June 16, 2022

Viewing posts 1–2 of 2

Hi,

I have set a custom post type for products and a custom taxonomy for product family.

I want to show a customized hero, and some hook elements (via Blocks element) to family archive page but it doesn't seem to load anything.

Elements applied:

  • One to merge header with the element.
  • One to show a page hero to family archive page
  • Another to show breadcrumbps in the hook generate_before_archive_title

In another hand, there's some way to apply some element to all archive from a custom taxonomy or to one term and all it's child terms?

Regards

Hi there,

for more complex display rules you can use the generate_element_display filter hook.

https://docs.generatepress.com/article/generate_element_display/

For example:

 add_filter( 'generate_element_display', function( $display, $element_id ) {
    $your_element_ids = array(123, 321, 213);
    if (  in_array( (int)$element_id, $your_element_ids ) && 'your_cpt_slug' == get_post_type() && is_archive() ) {
         $display = true;
     }
 
     return $display;
 }, 10, 2 );

First you would have your 3 x Elements set to NO Display Rule Locations.
Each of the Element IDs you load in: $your_element_ids array.

Then the condition checks if the element matches those IDs, that your your_cpt_slug matches the post type and is_archive to set its display rules to True

This archived topic is closed to new replies.