Drop-Down Menu of Current Child Pages

This can be approached by using wp_dropdown_pages() with the child_of parameter. global $post; $args = array( ‘child_of’ => $post->ID ); wp_dropdown_pages( $args ); The variable name will be $_GET[‘post_id’] or $_POST[‘post_id’], depending on your form settings, you can change the name by altering the name parameter. The value of the variable is the ID of … Read more

How to paginate a list of child pages

Option 1: Personally I prefer this, because it gives you more options in the long run. Especially considering other setups involving a secondary query, take a look at my other answer I linked below. What you need to do is, make use of the paged parameter WP_Query offers. Additionally you have to setup a variable … Read more

How to have a custom URI path for specific page template

You need to add a rewrite rule to WordPress. There are several options to do it depending on your exact needs. Maybe the most general is using add_rewrite_tag() and add_rewrite_rule(): add_action( ‘init’, ‘cyb_rewrite_rules’ ); function cyb_rewrite_rules() { add_rewrite_tag( ‘%variable1%’, ‘([^&]+)’ ); add_rewrite_tag( ‘%variable2%’, ‘([^&]+)’ ); add_rewrite_rule( ^system/([^/]*)/([^/]*)/?’, ‘index.php?pagename=$matches[1]&variable1=$matches[2]&variable2=$matches[3]’, ‘top’ ); } Now, if the URL … Read more

Exclude parent with child pages from WP_Query

the_dramatist’s answer will give you only top-level pages that have no children, which matches the example given in your description. However, if you want to get ALL leaf pages, use the following: SELECT * FROM $wpdb->posts WHERE post_type=”page” AND ID NOT in ( SELECT ID FROM $wpdb->posts WHERE post_type=”page” AND ID in ( SELECT post_parent … Read more

Get Child Page IDs by Parent ID

This should work. I’m not entirely sure what is wrong with your code (it’s getting late) but the below code works on my end. Obviously I replaced $order->get_id() with a known ID and post_type was set to page. <?php $parentid = $order->get_id(); $child = new WP_Query( array(‘post_parent’ => $parentid, ‘post_type’ => ‘shop_subscription’) ); if ($child->have_posts()) … Read more

query if page has not child

$args = array( ‘post_status’ => ‘publish’, ‘post_parent’ => $post_id ); $children = get_posts( $args ); if( count( $children ) > 0 ) { //has children } else { //does not have children } Docs: get_posts() This should also allow you to have access to the data of the children, should you need it. If you … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)