## $pages = get_pages(‘child_of=’.$post->ID); Why arguments are concatenated?

Question

I am reading a book called "Learn to Create WordPress Themes by Building 5 Projects" . In that to retrieve the parent for pages, they have a function to get the parent of the pages. The function is as follows,

function page_is_parent(){
global $post;$pages = get_pages('child_of=".$post->ID); return count($pages);
}


Explanation given in the book is as follows,

Now we just have About. We can navigate using the menu here. However, if we go to Sample Page or any other page, it”s going to still have this even though there’s no child links. So, we’ll create another short function in the functions.php file and call page_is_parent. Then, we’ll say global $post and set $pages equal to get_pages(), and in here, we’ll say 'child_of=" and concatenate the post ID. Next, we”ll say return and then, we want the number of pages, so we’ll count($pages): But I feel the $pages = get_pages('child_of=".$post->ID); is weird since they pass a string "child_of='.$post->ID Please explain why a string is passed and why it is concatenated.

0
1 month 2022-07-17T00:09:33-05:00 0 Answers 0 views 0