Site logo

[Support request] Layout related query

Home Forums Support [Support request] Layout related query

Home Forums Support Layout related query

Viewing 5 posts - 16 through 20 (of 20 total)
  • Author
    Posts
  • #2491449
    David
    Staff
    Customer Support

    I would suggest you follow some tutorials or get a developer, as this is custom development, and its not something we can teach or do for you.

    I can only assist a little:

    1. in that document, there is this code:

    function my_cptui_add_post_types_to_archives( $query ) {
    	// We do not want unintended consequences.
    	if ( is_admin() || ! $query->is_main_query() ) {
    		return;    
    	}
    
    	if ( is_category() || is_tag() && empty( $query->query_vars['suppress_filters'] ) ) {
    
    		// Replace these slugs with the post types you want to include.
    		$cptui_post_types = array( 'my_post_type', 'my_other_post_type' );
    
    		$query->set(
    	  		'post_type',
    			array_merge(
    				array( 'post' ),
    				$cptui_post_types
    			)
    		);
    	}
    }
    add_filter( 'pre_get_posts', 'my_cptui_add_post_types_to_archives' );

    Add the code to your site, this doc explains how:

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

    2.

    in that code you will see this line:

    $cptui_post_types = array( 'my_post_type', 'my_other_post_type' );

    where it says my_post_type and my_other_post_type change them to the slugs of your CPTs.

    #2491636
    Ajay

    i am using genratblocks pro can i achieve through that?

    #2491748
    David
    Staff
    Customer Support

    If you want post archives to include your CPTs you have to use the code above.
    GenerateBlocks won’t do that.

    #2492284
    Ajay

    Thanku so soo much code is working. You guys are amazing

    #2492603
    David
    Staff
    Customer Support

    Super happy to hear that. You’re welcome

Viewing 5 posts - 16 through 20 (of 20 total)
  • You must be logged in to reply to this topic.