Articles of children

Keep page hierarchy in wp_list_pages, even if on a child or grandchild

I have the following structure of pages, and I need to have that same structure displayed on those pages who have child pages: – Childpage – – Grandchildpage – – Other Grandchildpage – Other Childpage The following code is used to display the structure on page.php: <ul class=”sidemenu-list”> <?php if($post->post_parent) $children = wp_list_pages(“title_li=&child_of=”.$post->post_parent.”&echo=1″); else $children […]

(get_post_ancestors == 2) is returning true on 1 as well?

I am trying to use this code: <?php if(count(get_post_ancestors($post->ID)) == 2 ) : ?> <script>…</script> <?php endif ?> to add a script to a page but only if the page is a grandchild page (3rd level down, when it has 2 ancestors): Desired Result (with code above): Parent Page Child Page Grandchild Page (show script […]

How do I display child post types in the parent post type template

I have a custom post type called airports which uses a template called single-airports.php. I have created a new airport called Gatwick and created a child of this called called Gatwick North Terminal. How do I get the permalink of Gatwick’s children to display on the Gatwick page (single-airports.php). I would greatly appreciate any help […]

get_pages displays only parents instead of children

Hey there I am trying to fetch all direct children of a page. But I am getting only the parent two pages. Any ideas? Code: function childpages_func( ){ $args = array( ‘child_of’ => $post->ID, ‘parent’ => $post->ID, ‘hierarchical’ => 0, ‘sort_column’ => ‘post_date’, ‘sort_order’ => ‘menu_order’ ); $childpages = get_pages( $args ); foreach($childpages as $child){ […]

Display children category images

I have worked four hours on this but with no result. There is a custom taxonomy and I need to display the image of the child category but displays the image of parent category. My code is: <?php $term = get_term_by( ‘slug’, get_query_var( ‘term’ ), get_query_var( ‘taxonomy’ ) ); $queried_object = get_queried_object(); $term_id = get_queried_object() […]

Get only immediate children (and not grandchildren) of a hierarchical custom taxonomy term

Say, for example, I have the following custom taxonomy: Term 1 Term 1.1 Term 1.2 Term 1.2.1 Term 1.2.2 Term 1.3 Term 2 Term 2.1 How can I get the children terms of Term 1, not including grandchildren? That is, I want my results to include only Term 1.1, Term 1.2, and Term 1.3. Thanks.

Give Children Unique ID's

Is there a way I can give each wordpress children (subcategory UL lists) unique ID’s? I’m creating a dropdown list for subcategories and I want to position them but :nth-child isn’t supported by everything yet.

How can I make wp_list_categories output li with category-slug as class, for its children?

Simply put, I’d like to change the wp_list_categories output from this: <li class=”cat-item cat-item-1″><a href=”http://mysite.com/category/articles”>Articles</a></li> <li class=”cat-item cat-item-7″><a href=”http://mysite.com/category/design”>Design</a></li> to this instead: <li class=”cat-item category-articles”><a href=”http://mysite.com/category/articles”>Articles</a></li> <li class=”cat-item category-design”><a href=”http://mysite.com/category/design”>Design</a></li> So I tried Google and I’ve found a solution mentioned on this question add filter to wp_list_categories and query if used to list tax-terms? . […]

Child Category Image

I have some code that display’s the titles of my child category posts on one of my pages: <?php $parent = get_cat_ID(“photos”); $cats = get_categories(‘child_of=’.$parent); foreach ($cats as $cat) { echo “<ul>”; echo sprintf(“<li><a href=’%s’>%s</a></li>”, get_category_link($cat->term_id), apply_filters(“get_term”, $cat->name)); echo “</ul>”; } ?> Is there a way to also post a random featured image from the […]

Menu Arrow for Child Element

I have a menu for a website I am designing and there are parent and child elements…I was wondering if there was someway I could add an arrow to my navigation if the parent has a child element? My navigation code looks like: <div id=”nav”> <ul> <?php wp_list_pages(“title_li=”); ?> </ul> </div> My CSS code looks […]