Site logo

Archived topic

CPT archive disable masonry

5 replies · Started by melvin on July 8, 2021

Viewing posts 1–6 of 6

Hi,

My objective: have 3 columns in CPT archive, BUT disable/remove masonry in CPT

If I only use the below code for column, the CPT archive doesn't appear 3 column but it show only 1 column like this.

	// Highlight CPT, Highlight tax - Content Column Setting
	add_filter( 'generate_blog_get_column_count','ke_column_count_highlight_archive' );
	function ke_column_count_highlight_archive( $count ) {
		if ( is_post_type_archive( 'highlights') || is_tax( 'highlight_category' )) {
			return 33;
		}

		return $count;
	};

I've to add the masonary code only, only the CPT archive will appear in 3 column like this.

	// Highlight CPT, Highlight tax - Content Column Setting
	add_filter( 'generate_blog_get_column_count','ke_column_count_highlight_archive' );
	function ke_column_count_highlight_archive( $count ) {
		if ( is_post_type_archive( 'highlights') || is_tax( 'highlight_category' )) {
			return 33;
		}

		return $count;
	};

	// Project CPT, Project Tax - activate masonry (if not column not working)
	add_filter( 'generate_blog_masonry','ke_projects_masonry_project_archive' );
	function ke_projects_masonry_project_archive( $masonry ) {
		if ( is_post_type_archive( array('projects', 'highlights', )) || is_tax( array( 'project_status', 'project_location', 'project_type', 'highlight_category', ) ) ) {
			return 'true';
		}

		return $masonry;
	};

My objective: I want 3 column in my CPT archive, but do not want masonary. How to achive that?

Hi there,

This should be false if you want masonry disabled.

// Project CPT, Project Tax - activate masonry (if not column not working)
	add_filter( 'generate_blog_masonry','ke_projects_masonry_project_archive' );
	function ke_projects_masonry_project_archive( $masonry ) {
		if ( is_post_type_archive( array('projects', 'highlights', )) || is_tax( array( 'project_status', 'project_location', 'project_type', 'highlight_category', ) ) ) {
			return 'true';
		}

		return $masonry;
	};

returning true for highlights and projects CPT archive pages means you want masonry enabled = true for the specified CPTs.

Hi,

Thanks for your prompt reply.

I followed your instruction to make it to false

	// Highlight CPT, Highlight tax - Content Column Setting
	add_filter( 'generate_blog_get_column_count','ke_column_count_highlight_archive' );
	function ke_column_count_highlight_archive( $count ) {
		if ( is_post_type_archive( 'highlights') || is_tax( 'highlight_category' )) {
			return 33;
		}

		return $count;
	};

	// Project CPT, Project Tax - activate masonry (if not column not working)
	add_filter( 'generate_blog_masonry','ke_projects_masonry_project_archive' );
	function ke_projects_masonry_project_archive( $masonry ) {
		if ( is_post_type_archive( array('projects', 'highlights', )) || is_tax( array( 'project_status', 'project_location', 'project_type', 'highlight_category', ) ) ) {
			return 'false';
		}

		return $masonry;
	};

See the result, it doens't appear 3 column.

Please advise.

tq

add_filter( 'generate_blog_columns','tu_portfolio_columns' );
function tu_portfolio_columns( $columns ) {
    if ( is_post_type_archive( array('projects', 'highlights', )) || is_tax( array( 'project_status', 'project_location', 'project_type', 'highlight_category', ) ) ) {
        return true;
    }

    return $columns;
}

Add this filter.

Usage reference - https://docs.generatepress.com/article/using-columns-in-the-blog/

Elvin,

Thanks! It's resolved.

I appreciate it very much!

Thank you.

No problem. Glad to be of any help. :D

This archived topic is closed to new replies.