Site logo

Archived topic

how to create related posts with generateblocks?

27 replies · Started by eran on July 17, 2022

Viewing posts 1–15 of 28

Hi, how can i make related posts in the right sidebar that when im in a page the sidebar will show all the brothers page of the page?
plus, if im in the parent page i want to display all the child pages.

is it possible with generateblocks?

I understand.
But I don't know how to achieve it.
What should I chhose in the parameters?

But I don't use categories on my menu i use pages. it will still work?

You’re right, it wouldn’t work.

Try Parent > Current Post to show all Child pages: https://share.getcloudapp.com/6quzweGg

Then, to get all siblings, add my-query to the Grid Block of the Query Loop, and add this PHP snippet:

add_filter( 'generateblocks_query_loop_args', function( $query_args, $attributes ) {
		if ( ! empty( $attributes['className'] ) && strpos( $attributes['className'], 'my-query' ) !== false ) {
			global $post;
			$query_args['post_parent'] = $post->post_parent;
		}

		return $query_args;
	}, 10, 2 );

Adding PHP reference: https://docs.generatepress.com/article/adding-php/#code-snippets

Kindly let us know how it goes.

I need to add "my-query" to the grid block as a class?

I dont have the option for current post.
I try to make this through generatepress elements.

Yes I have the generateblocks pro Version 1.5.4
I dont have the option current post.
I can choose a single page but i want this to apply on all the pages.

oh now I see.
why I didnt get a message for the update?
every update I need to download the update from the generateblocks website?

In the GenerateBlock settings, you need to have your license key added and saved and the Receive beta updates toggle enabled if you want to see the alpha/beta updates.

I update for 1.3 version
its still doesnt work.

This archived topic is closed to new replies.