Site logo

[Resolved] Broken CPT archive with FacetWP filter fix

Home Forums Support [Resolved] Broken CPT archive with FacetWP filter fix

Home Forums Support Broken CPT archive with FacetWP filter fix

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #2582964
    Jens

    Dear Generatepress team,

    we are using Generatepress and Generateblocks. Additionally we have FacetWP on two archives (links in private information).

    As the FacetWP filters were not showing we used a proposed fix from the support forum here which made the filters appear.

    /**
     ** add facetwp-template div around main content area in GeneratePress
     **/
    
    add_action('generate_before_main_content', function(){
        if ( is_post_type_archive( 'template' ) || is_tax( 'template-type' ) || is_tax( 'template-style' )) {
            ?><div class="facetwp-template"><?php
        }
    });
    
    add_action('generate_after_main_content', function(){
        if ( is_post_type_archive( 'template' ) || is_tax( 'template-type' ) || is_tax( 'template-style' )) {
            ?></div><?php
        }
    });
    
    add_action('generate_before_main_content', function(){
        if ( is_post_type_archive( 'jobs' ) || is_tax( 'job-group' ) ) {
            ?><div class="facetwp-template"><?php
        }
    });
    
    add_action('generate_after_main_content', function(){
        if ( is_post_type_archive( 'jobs' ) || is_tax( 'job-group' )) {
            ?></div><?php
        }
    });

    Unfortunately the cards that we had generated get broken with that fix somehow. Please note, that we also use another code from the forum here to show the cards in a four column layout:

    /* Columns for template archive */
    
    add_filter( 'generate_blog_columns','tu_portfolio_columns' );
    function tu_portfolio_columns( $columns ) {
        if ( is_post_type_archive( 'template' ) || is_tax( 'template-type' ) || is_tax( 'template-style' ) ) {
            return true;
        }
    
        return $columns;
    } 
    
    add_filter( 'generate_blog_get_column_count', function( $column_width ) {
        if ( is_post_type_archive ( 'template' ) || is_tax( 'template-type' ) || is_tax( 'template-style' ) ) {
            return '25';
        }
    
        return $column_width;
    } ); 
    
    add_filter( 'generate_blog_columns','tu_jobs_columns' );
    function tu_jobs_columns( $columns ) {
        if ( is_post_type_archive( 'jobs' ) || is_tax( 'jobs-group' ) ) {
            return true;
        }
    
        return $columns;
    } 
    
    add_filter( 'generate_blog_get_column_count', function( $column_width ) {
        if ( is_post_type_archive ( 'jobs' ) || is_tax( 'jobs-group' ) ) {
            return '25';
        }
    
        return $column_width;
    } ); 

    Many thanks in advance!

    #2583063
    Ying
    Staff
    Customer Support

    Hi there,

    Can you try adding this CSS?

    .facetwp-template {
        display: flex;
        flex-wrap: wrap;
    }

    Adding CSS: https://docs.generatepress.com/article/adding-css/

    For the block element – content template (jobs), can you remove the facetwp-template class from the GB container?
    https://www.screencast.com/t/VmINbDB6bHD

    #2583680
    Jens

    Thanks a lo! That did the trick.

    #2584409
    Ying
    Staff
    Customer Support

    Glad to hear that 🙂

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.