I need to tell whether or not the current custom taxonomy archive page I'm viewing has child categories. I've got a situation where there are a lot of custom categories with children and the site is only to show posts at the end of the line. Otherwise it should show a link to the category that's the next step down. I've found this snippet, but it doesn't seem to work for custom taxonomies. function category_has_children() { global $wpdb; $term = …
Targets : Show Locations (sub-districts & cities) on the customized shop page & on tab additional information - Show on line 5 I'm building a property site using wordpress and woocommerce. In my country has 7 islands, 34 provinces, 514 Cities, 7041 Districts, 82194 Sub-districts. Then I grouped the data and added it to : On category Verified (parent) Sold (parent) Rent (parent) Island #1 (parent) province #1 (child) City #1(sub-child) Island #2 (parent) province #2 (child) City #2(sub-child) Island …
I'm experiencing some interesting results using post_parent along with post_type (local, WP 5.8): I have a custom post type project (with 'hierarchical' => true) where I'm grabbing all child posts of a parent on a single view using WP_Query. When setting post_type to project while setting post_parent I get the same results as if I had not set a post_parent at all: that is, I get all top-level posts with a custom post type of project. If I set the …
I want to display the child pages of the current page you are on. <?php wp_list_pages('child_of=67&sort_column=menu_order&title_li=') ?> If I give the id number like above it works perfectly like this: However I want to use this as a template for multiple pages, but when I use the ID or get Id or echoing the ID, it also take the sibling pages of the parent page. Which I don't need. <?php wp_list_pages('child_of=the_ID()&sort_column=menu_order&title_li=') ?> I can't figure it out what I am …
I am trying to dynamically insert a page/multiple pages as a child under the current page in my template file, using wp_insert_post, however I need to first check if the page title already exists under the current page, and if it doesn't exist then to run the code and create the page(s), but don’t want it to create a duplicate page under the current page if the title already exist under the current page only. The get_page_by_title seems to check …
The following code displays the parent plus its children on the specific parent - and children-category pages as "filter-buttons". But in this list I do not want to display the parent, (because the parent is already displayed as "ALL"). How can I display list with only the children without the parent? Thank you for any further help. <?php $categories = get_the_category(); foreach($categories as $key => $category) { $url = get_term_link((int)$category->term_id,'category'); $categories[$key] = "<pre><a href=\"{$url}\">{$category->name}</a></pre>"; } echo "" . implode("\n",$categories) . …
I am trying to display a sub-menu with the sub-pages of a parent, if you are on the parent page, and the siblings if you are on one of the child pages, but the problem is that if the page have a featured image is recognized az a parent. this is the code I use: // check if page have children $children = get_children( get_the_ID() ); if ( ! empty($children)) { echo '<ul class="submenu">'; wp_list_pages(array( 'child_of' => $post->ID, 'title_li' => …
I was able to get all the items of a custom taxonomy for a post, like this: $args=array('orderby'=>'parent',"fields" => "all"); $term_list = wp_get_post_terms($post->ID, 'tvr_amenity', $args); My problem is that i would like to show the tree (respecting the parents) So i would like to get them ordered by name and parent but i cant find anything related on codex.. any idea how?
I am looking to get immediate children of a page ID. I tried below code, but it does not seem to work $pageIDchild = get_pages( array ( 'parent' => 0, 'child_of' =>$pageID, 'sort_column' => 'menu_order' ) ); Any help is greatly appreciated. Thanks!
hi everyone from the codex I found what I needed that is to show the sub-taxonomies by specifying the id of the sub-taxonomy and the macro taxonomy get_term_children( int $term_id, string $taxonomy ) with the example shown <?php $term_id = 10; $taxonomy_name = 'products'; $termchildren = get_term_children( $term_id, $taxonomy_name ); echo '<ul>'; foreach ( $termchildren as $child ) { $term = get_term_by( 'id', $child, $taxonomy_name ); echo '<li><a href="' . get_term_link( $child, $taxonomy_name ) . '">' . $term->name . '</a></li>'; …
I would like to display a list of child terms according to my current taxonomy. Taxonomy name ='course' Photoshop(=child term) ps-thematic#1(= child child term) ps-thematic#2 ... After Effects ae-thematic#1 ae-thematic#2 ... Another course zz-thematic#1 So, in my taxonomy-course-photoshop.php, I'd like to display ps-thematic#1, ps-thematic#2, etc. I found plenty of questions and answers on this subject. I tried many them. Without success... So now, I just feel very confused between get_terms, get_children_term. Or $args= array('parent' => $this_term->term_id,...} My last try was …
I'm trying to make a category counter, but it's not really working. I want to have a common counter of all categories (1168), which I would later display. For example: 1 category is the first level 6 categories of the second level 13 categories of the third level 56 categories of the fourth level 158 categories of the fifth level 934 categories of the sixth level How do I implement this with get_terms? Things I've tried so far: I have …
I have a custom archive page(with map and location data) for a custom post type. Due to how the locations are hierarchal(state, city, location), I want to show the states only on the archive page, and a count of the grand-children on the marker(using google maps API). The marker with text is working great, as is grabbing only the top level locations. The issue I'm having is getting an accurate count. This is my current code. I've tried get_posts, get_pages, …
I want to edit the following piece of code: <?php if ( (!$theretailer_theme_options['category_listing']) || ($theretailer_theme_options['category_listing'] == 0) ) { ?> <!-- Show only the first category--> <?php $gbtr_product_cats = strip_tags($product->get_categories('|||', '', '')); //Categories without links separeted by ||| ?> <h3><a href="<?php the_permalink(); ?>"><?php list($firstpart) = explode('|||', $gbtr_product_cats); echo $firstpart; ?></a></h3> <?php } ?> Example: http://tjwillems.nl/priveekollektie/product-category/artists/reinier-bosch/ The red-title under the product image only needs to show the child categories of 'artist'. So for example only 'Reinier Bosch' and not 'Lighting' Can …
So I am interested in allowing a custom menu to show "in three places: Menu area, Homepage body, and footer" based on the posttype "page" table list or parent and children entries and not using the WP nav menu system. Reason is, I want users to control the menus displaying of my site using custom fields on each page. All 3 menus on the site will parent titles (w/ children page titles in the header menu only), but all with …
I have here hardcoded category id so I can pull in needed categories and their posts by category. But ideally I would like to get this by calling parent category to list child and post. My code works but that's not how I would like to do it and would like to hear any suggestions to improve. I'm still trying to figure this out myself as well. Parent category is 'winners-2018'. <?php $catz = array(6012,6013,6014,6015,6016); foreach($catz as $i=>$categ){ $cat_archive = …
Client wants to show how many images await the reader in a post. I say: easy peazy. Now I realize: I lied. The system only uses galleries, even for single pictures. $images = get_children(array( "post_parent" => $post->ID, // $post->ID gives the right ID. "post_status" => "any", "post_type" => "attachment", "post_mime_type" => "image" )); count($images); // only post with id 12 shows correctly 14 entries In one post (ID 12, an eaaarly test entry) $images is filled with the correct amount …