How to get post id of first child of the same post type?

Instead of: $args = array( ‘order’ => ‘ASC’, ‘orderby’ => ‘menu_order’, ‘post_type’ => ‘attachment’, ‘post_parent’ => $post->ID, ‘post_mime_type’ => ‘image’, ‘numberposts’ => 1, ); Use: $args = array( ‘order’ => ‘ASC’, ‘orderby’ => ‘menu_order’, ‘post_type’ => get_post_type($post), ‘post_parent’ => $post->ID, ‘numberposts’ => 1, ); You could also use post/page/etc or ‘any’

Display Child Categories of Current Post ID

For actual categories: <ul> <?php global $post; // grab categories of current post $categories = get_the_category($post->ID); // define arguments of following listing function $args = array ( ‘child_of’ => $categories[0], // current post’s (first) category ‘title_li’ => ” // disable display of outer list item ); // list child categories wp_list_categories($args); ?> </ul> The same … Read more

Check for parent category

The correct syntax of cat_is_ancestor_of is cat_is_ancestor_of( $parent_cat_id, $child_cat_id ); Where: $parent_cat_id: should be the id to check if this is the parent category, in your case it should be 526. $child_cat_id: should be the id of the child category.

Only looping through pages that have children or subpages

I just figured out the answer to my own question. It works by counting the number of children pages using get_pages. Here is the working code: <?php $children = get_pages( array(‘child_of’ => $post->ID,’post_type’=>’custom-post-type-name’)); if( count( $children ) != 0 ) { ?> <h1><a href=”https://wordpress.stackexchange.com/questions/46090/<?php the_permalink(); ?>”><?php the_title(); ?></a></h1> <?php } else { } ?>

Want Page Descendants when using query_posts post_parent or child_of

If you don’t have to use query_posts() then this is one method: function my_menu() { global $post; if(!$post->post_parent){ // will display the subpages of this top level page $children = wp_list_pages( array( ‘title_li’ => ”, ‘child_of’ => $post->ID, ‘echo’ => 0 ) ); } elseif($post->ancestors){ // diplays only the subpages of parent level $ancestors = … Read more

Can you exclude child pages of a specific parent within a navigation?

try -: if your page ID = 999 <?php $child_ids = $wpdb->get_col(“SELECT ID FROM $wpdb->posts WHERE $wpdb->posts.post_parent = 999 AND $wpdb->posts.post_type=”page” AND $wpdb->posts.post_status=”publish” ORDER BY $wpdb->posts.ID ASC”); $exclude = implode($child_ids,’, ‘); wp_list_pages(‘exclude=” . $exclude . “&title_li=<h2>’ . __(‘Pages’) . ‘</h2>’); ?>

Check is category parent with ids from the childs – get_term_children

Sry, here is my answer: Here is first the output for listing the category in checkbox: Walker for the Category Output class Adv_Multicheck_Walker_Category extends Walker { var $tree_type=”category”; var $db_fields = array (‘parent’ => ‘parent’, ‘id’ => ‘term_id’); function start_lvl($output, $depth, $args) { if ( ‘list’ != $args[‘style’] ) return $output; $indent = str_repeat(“\t”, $depth); … Read more

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