WordPress get the child pages of current page
<?php $current_page_id = get_the_ID(); wp_list_pages(“child_of={$current_page_id}&sort_column=menu_order&title_li=”); ?> Please check the above code
<?php $current_page_id = get_the_ID(); wp_list_pages(“child_of={$current_page_id}&sort_column=menu_order&title_li=”); ?> Please check the above code
Use wp_get_attachment_image( $id ). Sample code: print wp_get_attachment_image( $main_image, array ( 80, 80 ), FALSE, array ( ‘alt’ => ‘portrait’ ) );
sort_column is not a valid parameter for WP_Query. You want orderby. sort_order is also not a valid parameter. It should just be order. $all_wp_pages = $my_wp_query->query( array( ‘post_type’ => ‘page’, ‘order’ => ‘ASC’, ‘orderby’ => ‘menu_order’ ) ); The Codex is your friend.
Instead of putting something on the template, you can keep templates clean and add to functions.php a function that use ‘template_include’ action hook to check parent page template and return same template for children pages. add_action(‘template_include’, ‘auto_child_template’); function auto_child_template( $template=”” ) { if ( ! is_page() ) { return $template; } else { $page = … Read more
If I read your question correctly you just need to set the ‘about’ page as a parent to ‘contact’ and ‘opening hours’ then the permalink will be how you want it. To do this go edit page of ‘contact’ and in the page attributes box set the parent to ‘about’ page.
You’re close, the query var for passing page slug is pagename: add_filter(‘query_vars’, ‘add_account_edit_var’, 0, 1); function add_account_edit_var($vars){ $vars[] = ‘account-edit’; return $vars; } add_action( ‘init’, ‘add_account_edit_rule’ ); function add_account_edit_rule() { add_rewrite_rule( ‘^my-account/([^/]*)/?’, ‘index.php?pagename=my-account&account-edit’, ‘top’ ); } To capture the value in your rule, you need to pass the value in $matches[1]: add_rewrite_rule( ‘^my-account/([^/]*)/?’, ‘index.php?pagename=my-account&account-edit=$matches[1]’, ‘top’ … Read more
wp_list_pages can take child_of param, to show only pages that are children of given page. But you have to pass the ID of that parent page (so you can’t put a slug in there). But you can use get_page_by_path to get a page object based on slug of the page. And another thing you have … Read more
Updated Answer — @Quasimodo confirmed that they’re only interested in posts of the page type and that the numeric slugs are four-digit years, e.g. 2019. What can I do to allow numeric slugs for child pages? I would use the pre_wp_unique_post_slug hook that runs prior to wp_unique_post_slug, which means we’ll be filtering the slug before … Read more
Custom taxonomies are not meta values, but rather their own thing. I don’t think wp_list_pages() or get_pages() can query based on a taxonomy, so I’d recommend using WP_Query instead: <?php $relevant_pages_args = array( ‘post_type’ => ‘page’, ‘posts_per_page’ => -1, ‘post_parent’ => 65, ‘tax_query’ => array( array( ‘taxonomy’ => ‘relevance’, ‘field’ => ‘slug’, ‘terms’ => ‘alumni’ … Read more
You can filter template_include and replace the single-community.php with a single-child-community.php. Example add_filter( ‘template_include’, function( $template ) { if ( ! is_singular() ) return $template; // not single if ( ‘communities’ !== get_post_type() ) return $template; // wrong post type if ( 0 === get_post()->post_parent ) return $template; // not a child return locate_template( ‘single-child-community.php’ … Read more