Sunday, July 17, 2022
HomeWordPress Development$pages = get_pages('child_of='.$post->ID); Why arguments are concatenated?

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


I’m studying a e book referred to as "Study to Create WordPress Themes by Constructing 5 Tasks" . In that to retrieve the guardian for pages, they’ve a perform to get the guardian of the pages. The perform is as follows,

perform page_is_parent(){
world $publish;
$pages = get_pages('child_of=".$post->ID);
return rely($pages); 
}

Rationalization given within the e book is as follows,

Now we simply have About. We will navigate utilizing the menu right here. Nonetheless, if we go to Pattern Web page or another web page, it”s going to nonetheless have this regardless that there is no youngster hyperlinks. So, we’ll create one other quick perform within the capabilities.php file and name page_is_parent. Then, we’ll say world $publish and set $pages equal to get_pages(), and in right here, we’ll say 'child_of=" and concatenate the publish ID. Subsequent, we”ll say return after which, we wish the variety of pages, so we’ll rely($pages):

However I really feel the $pages = get_pages('child_of=".$post->ID); is bizarre since they go a string "child_of='.$post->ID Please clarify why a string is handed and why it’s concatenated.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments