Getting grandchildren of a post with a specified custom taxonomy?

I was able to achieve this by, funnily enough, using with get_pages() and WP_Query(). I wanted a reusable function that would return a WP_Query array that I could loop through, so I came up with this: function returnChildGeographies($geoID, $geoType, $grandChildren = false) { $args = array( ‘post_type’ => ‘geographies’, ‘posts_per_page’ => -1, ‘orderby’ => ‘post_title’, … Read more

Cross post type parent page added parent page to permalink but give 404

I think that you need only to change the way get_permalink create url for the cpt, ignoring the parent. You can do it adding a filter to ‘post_type_link’ hook and then regenerate the permalink for the product cpt in the same way is done in core, just ignoring the parent: add_filter(‘post_type_link’, ‘reset_light_link’, 999, 3); function … Read more

Determine if Term has Grandparent/Great-Grandparent

Use get_ancestors() and count the returned array: that’s the number of ancestors a term has. /** * Count a term’s ancestors. * * @param int $term_id * @param string $taxonomy * @return int */ function wpse_57512_count_ancestors( $term_id = FALSE, $taxonomy = FALSE ) { if ( FALSE === $term_id and ! empty ( get_queried_object()->taxonomy ) … Read more