- This topic has 28 replies, 4 voices, and was last updated 1 year, 7 months ago by David.
-
AuthorPosts
-
August 29, 2022 at 10:16 pm #2327900Fernando Customer Support
Here’s an article you may refer to with regards to uploading screenshots: https://docs.generatepress.com/article/using-the-premium-support-forum/#uploading-screenshots
August 29, 2022 at 10:19 pm #2327903August 29, 2022 at 10:27 pm #2327906Fernando Customer SupportTo clarify, is that screenshot from the “edit” page of best-camera-for-streaming?
Can you try checking if its at the very bottom of the page under all the content?
August 29, 2022 at 10:37 pm #2327908eranFound, it was under all the content thank you!
how can I make related posts in the child pages that will show the sibling pages + the parent page?August 30, 2022 at 6:37 am #2328274eranhow can I make related posts in the child pages that will show the sibling pages + the parent page?
August 30, 2022 at 7:08 am #2328301DavidStaffCustomer SupportHi there,
you would need to custom code to do that. The Theme doesn’t handle that. And GenerateBlocks Query Loop cannot handle that either.
WordPress has the
wp_list_pages
function you can use:https://developer.wordpress.org/reference/functions/wp_list_pages/
Heres an example snippet that creates a
[page_siblings]
shortcode, which will show parent and sibling pagesadd_shortcode('page_siblings', function(){ ob_start(); global $post; wp_list_pages( array( 'child_of' => $post->post_parent, 'exclude' => $post->ID, 'depth' => 1 ) ); return ob_get_clean(); });
August 30, 2022 at 7:28 am #2328317eranI dont know how to do that.
Is this something you work on generateblocks?August 30, 2022 at 7:35 am #2328330DavidStaffCustomer SupportGenerateBlocks can currently list Child Pages. In the future we may review and allow it to display Siblings.
But if you want Parent and Siblings then the best method is thewp_list_pages
function in WP.The code i provided above is a PHP Snippet. This doc explains how to add PHP:
https://docs.generatepress.com/article/adding-php/
TLDR: Are you using a Child Theme?
If Yes, then you add that code to the Child Themes functions.php
If No, then install the code snippets plugin ( link can be found in the doc above ) and add New Snippet to add the code.With that code added, you can add a Shortcode block to your page and add
[page_siblings]
inside that block.August 30, 2022 at 7:38 am #2328335eranAnd then i need to add the related posts block to that page? Or only the php code is enough?
August 30, 2022 at 7:50 am #2328486DavidStaffCustomer SupportNo.
You first add the PHP Snippet to your theme.
Either in the Child Theme functions.php or Code Snippets.Then you just add a Shortcode Block and inside it paste:
[page_siblings]
Thats it.
August 30, 2022 at 12:22 pm #2328733eranIt worked but without the parent page.
anyway to add the parent page?August 31, 2022 at 1:51 am #2329126DavidStaffCustomer SupportWhat do you want to happen if you’re on the Parent page ?
August 31, 2022 at 2:48 am #2329171eranParent page – related pages of all child pages. (Done with generatepblock).
Child page – related pages of sibling + parent page. How can i do that?
September 1, 2022 at 2:16 am #2330242DavidStaffCustomer SupportSorry i thought i had answered this.
Change the shortcode snippet to:add_shortcode('page_siblings', function(){ ob_start(); global $post; if ( $post->post_parent ) { echo '<a href="' . $post->post_parent . '" >' . get_the_title( $post->post_parent ) . '</a>'; } wp_list_pages( array( 'child_of' => $post->post_parent, 'exclude' => $post->ID, 'depth' => 1 ) ); return ob_get_clean(); });
-
AuthorPosts
- You must be logged in to reply to this topic.