1

I am migrating a site from a page builder to a block theme.

In my main post template I want to list other posts in the same category as the current post, excluding the current post itself.

In the page builder, filtering the equivalent blog post list was simple a case of choosing 'current category' from a dropdown, but it's not supported in the default Wordpress Query Loop block.

I was hoping to build a block variation for the Query Loop block but have been unable to work out what I need to do to automatically filter the results in the block based on the current post's category.

wp.blocks.registerBlockVariation(
'core/query',
{
    name: 'related-latest-posts',
    title: 'Related Latest Posts',
    description: 'Displays related posts',
    attributes: {
        postsToShow: 3
    },
    query: {
        postType: 'post',
        postStatus: 'publish',
        orderby: 'date',
        order: 'desc',
        perPage: 3
    }
}

);

1 Answer 1

1

Curious if you ever figured this one out? I'm running into a similar situation.

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.