Site logo

Archived topic

Broken CPT archive with FacetWP filter fix

3 replies · Started by Jens on March 26, 2023

Viewing posts 1–4 of 4

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!

Thanks a lo! That did the trick.

Glad to hear that :)

This archived topic is closed to new replies.