Are you a GenerateCustomer?

Do you have an active GP Premium or GenerateBlocks Pro license key?

Create a GenerateSupport account for GeneratePress and GenerateBlocks support in one dedicated place.

Create an account
Already have a GenerateSupport account? Login

Just browsing?

Feel free to browse the forums. Support for our free versions is provided on WordPress.org (GeneratePress, GenerateBlocks).

Want to become a premium user? Learn more below.

How to recreate elements?

  • Hi There,

    I’m working with the scribe starter site trying to recreate the scribe posts grid on the blog archive on a custom post type archive. I’ve duplicated the ‘archive cards’ template and applied this to the custom post type archive but the grid is not applied. Nor can I see where the grid element is applied within the content template. Grid I’m trying to recreate https://mwprop.ogmaworks.com/ cpt archive with copied template here https://mwprop.ogmaworks.com/provider-profiles/

    Any help would be great.

    Thanks

    Dave

  • Hi there,

    The columns are not activated for CPT, you will need to use PHP code to activate it.

    add_filter( 'generate_blog_columns', function( $columns ) {
        if ( 'provider_profile' === get_post_type() && ! is_singular() ) {
            return true;
        }
    
        return $columns;
    } );

    Adding PHP: https://docs.generatepress.com/article/adding-php/

    For more info, please check this guide:
    https://docs.generatepress.com/article/using-columns-in-the-blog/#adding-columns-to-your-custom-post-type

  • Thanks Ying,

    Much appreciated. I’m now looking to remove the featured post from the cpt archive, but I’d like to keep it on the posts archive. If I uncheck the customizer option, then it removes from both archives.

    Thanks Again

    Dave

  • Try replacing the previous code with this new code:

    add_filter( 'option_generate_blog_settings', 'yh_custom_cpt_settings' );
    function yh_custom_cpt_settings( $options ) {
        if ( 'provider_profile' === get_post_type() && ! is_singular()) {
    	$options['column_layout'] = true;
    	$options['featured_column'] = false;
        }
      
        return $options;
    }

    Let me know if this helps!

  • Thanks very much, I had a bit of a play with that but with a little AI help I’ve got there I think, all look ok to you?

    
    add_filter( 'generate_blog_columns', function( $columns ) {
        if ( 'provider_profile' === get_post_type() && ! is_singular() ) {
            return true; // Enables columns
        }
        return $columns;
    } );
    
    add_filter( 'option_generate_blog_settings', function( $options ) {
        if ( 'provider_profile' === get_post_type() && ! is_singular() ) {
            $options['featured_column'] = false; // Disable featured column
        }
        return $options;
    } );
  • Looks good 🙂

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