PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Monday, April 11, 2022

[FIXED] Wordpress do term is child of something term

 April 11, 2022     parent-child, taxonomy-terms, wordpress     No comments   

Issue

For example I have term 'child', how to check do this term is child of term 'Mother' ?


id='dv4'>

Solution

As per your comments I think you can do this in the below mentioned manner -

Place this method in your theme functions.php file

function is_child($pageID) { 
    global $post; 
    if( is_page() && ($post->post_parent==$pageID) ) {
               return true;
    } else { 
               return false; 
    }
}

Then you can use this method anywhere in your theme --

<?php
if(is_child(343)) {
echo "This is a child page of 'The Parent Page Title'.";
}
?>

Reference - http://bavotasan.com/2009/check-if-a-page-is-a-child-of-another-page-in-wordpress/



Answered By - swapnesh
Answer Checked By - Timothy Miller (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing