Get all children page ID’s including parent by title

You have done this the hard way. WP_Query can do most of the work for you. function get_all_pages($page_title) { $page = get_page_by_title($page_title); if (empty($page)) return array(); $children = new WP_Query( array( ‘post_type’ => ‘page’, ‘post_parent’ => $page->ID, ‘fields’ => ‘ids’ ) ); array_unshift($children->posts,”{$page->ID}”); return $children->posts; } $allpages = get_all_pages(‘Sample Page’); var_dump($allpages); It is late, and … Read more

How to use the same code for multiple pages?

Please show us your actual code, and don’t just describe what you implemented. In this particular case, it is vital to see how you tried to implement two occurrences of the code. Anyway, from what I understand, the following function should do what you’ve asked for: add_action(‘wp_trash_post’, ‘wpse_136052_do_not_delete’); function wpse_136052_do_not_delete($id) { if (in_array(get_post($id), array( get_page_by_title(‘About’), … Read more

Personal page for every user (not just authors)

I guess what you’re looking for is an author template. You can create an author.php in your template folder and arrange the information in there like you want to. It will be a general template for every user then. You can access the author page if you visit example.com/author/author-slug/ To give an example: http://bookish.brokenstars.de/author/fyn/ I’m … Read more

Set if condition with wp_nav_menu

No need to use conditional here to hide your nav menu when it is empty. Have a look at wp_nav_menu( $args );. It accepts the following arguments $defaults = array( ‘theme_location’ => ”, ‘menu’ => ”, ‘container’ => ‘div’, ‘container_class’ => ”, ‘container_id’ => ”, ‘menu_class’ => ‘menu’, ‘menu_id’ => ”, ‘echo’ => true, ‘fallback_cb’ … Read more

Missing parent page attribute

Ok, I solved it myself. The Drop-down list is only displayed if there is at least one public page. Why there is not just “There is no public page” text instead of hiding the list without a hint!? I have set every page to private, so that the list was not displayed at all. If … Read more

Page title not showing up

to show the page title for the page set as the ‘blog’ or ‘posts page’, you need to add some code, maybe via a filter on wp_title(); example: add_filter( ‘wp_title’, ‘wpse_174379_show_posts_page_wp_title’ ); function wpse_174379_show_posts_page_wp_title( $title ) { if( get_option( ‘page_for_posts’ ) ) { $posts_page = get_post( get_option( ‘page_for_posts’) ); $title=” ” . $posts_page->post_title . ‘ … Read more

Show child pages and sibling pages on the child page

You can query pages that have same parent excluding the page itself: wp_list_pages(“title_li=&child_of=”.$post->post_parent.”&exclude=”.$post->ID); Use parent instead of child_of to get only direct siblings without children of the siblings.

Dynamically change page that loads

Wp load pages based on it’s main query. SO if you want to load a different page, then you may have to alter the main query with th e pre_get_posts hook.If you want to know more.Then please specif what and how you want to load different page in details