-
aesthetik
@Ying, I was trying to add pagination to my archive page but was looking in the wrong place. I was checking “Appearance > Customize”, but realize its a button that is part of the Query Loop block.
All good. Thank you all for all your help! This has been a game changer.
-
Glad to hear that 🙂
-
aesthetik
Hey guys, sorry to come back to this so late, but curious how I would edit the code here to add a 3rd or 4th post type to the mix? I tried two different code types (below), but its not working. Any tips on what I could do to get it working?
/* Removes REGULAR post template on LINK or VIDEO posts, LINK post template on REGULAR or VIDEO posts, and VIDEO post template on REGULAR or LINK posts */ add_filter( 'render_block', function( $block_content, $block ) { if ( !is_admin() && ! empty( $block['attrs']['className'] ) && strpos( $block['attrs']['className'], 'post-template' ) !== false ) { $current_post_type = get_post_type(); // Remove 'regular-post' template on LINK or VIDEO posts if ( strpos( $block['attrs']['className'], 'regular-post' ) !== false && $current_post_type !== 'post' ) { return ''; // Hide block } // Remove 'custom-post' (LINK) template on REGULAR or VIDEO posts if ( strpos( $block['attrs']['className'], 'custom-post' ) !== false && $current_post_type !== 'links' ) { return ''; // Hide block } // Remove 'video-post' template on REGULAR or LINK posts if ( strpos( $block['attrs']['className'], 'video-post' ) !== false && $current_post_type !== 'video' ) { return ''; // Hide block } } return $block_content; }, 99, 2 );
then updating the original code provided:
/* Removes REGULAR post template on LINK post, and LINK post template on REGULAR Post */ add_filter( 'render_block', function( $block_content, $block ) { if ( !is_admin() && ! empty( $block['attrs']['className'] ) && strpos( $block['attrs']['className'], 'post-template' ) !== false ) { $current_post_type = get_post_type(); if ( ( strpos( $block['attrs']['className'], 'regular-post' ) !== false && $current_post_type !== 'post' ) || ( strpos( $block['attrs']['className'], 'custom-post' ) !== false && $current_post_type === 'post' ) ) { return ''; // Return nothing if either condition is met. } } return $block_content; }, 99, 2 );
-
The first filter name is wrong, it should’ve been
generateblocks_query_loop_args
. -
aesthetik
Thanks @Ying. That helped a bit.
I’ll keep this as resolved and opened a new ticket as I had a few more questions about this and updating to new query block 2.0. -
I’ve replied to your new ticket 🙂
- You must be logged in to reply to this topic.