Tag Info

New answers tagged


Something is changing your results from get_ancestors() or something is changing your query which "changes" your child pages to grandchild pages when queried on the page. It also seems from comments that the post ID's does not stay constant on the page. What immediately catches my eye from your updated code is that your custom query is not resetted after ...


Try checking the $post->ID right at the wp hook: add_action('wp','your_awesome_function'); function your_awesome_function() { global $post; if( count(get_post_ancestors($post->ID)) == 2 ) add_action('wp_footer','your_grandchild_script'); } function your_grandchild_script() { ob_start(); ?> ...


I don't know why that code didn't work for you. I copy that code and it work exactly as I expected. You should double check your case, did you unset $args variable before, or you can use another name ($agrs2 for example). Another problem in you question is: if pad_counts doesn't work, you will get 1 not 3.

Top 50 recent answers are included