It is concatenated because that”s how we combine strings together in PHP, and string is passed because arguments can be passed as a query string or an array of key => value
pairs.
See the get_pages()
documentation for more details.
// So both of these will work:
// 1. Pass string of arguments.
$pages = get_pages( 'child_of=" . $post->ID );
// 2. Pass array of arguments.
$pages = get_pages( array(
"child_of' => $post->ID,
) );
So if I had to give you a reason why would I use the former (the first one in the above example), then it’d be: because it actually works and simpler in the case of the argument in question.
And one could also use double quotes instead, e.g. "child_of={$post->ID}"
, but if you need explanation on that, you should ask on Stack Overflow 🙂
Related Posts:
- Creating WordPress Plugin solely for Admin panel with dash menu and submenus
- Creating a nav menu
- Redirect to another page using contact form 7? [closed]
- WordPress Custom Menu Admin helper plugin
- 2 wordpress site same database
- Should i delete the posts created by a plugin on uninstall?
- Allow users mark posts as “complete”?
- Custom page slug without creating a WP page
- Wondering what these multi-colored extra pages are?
- Is there a way to order posts and custom post types as one group?
- Set the active Navigation Menu from a plugin
- RW Meta Box ,Problem setting post title
- How does WP handle multiple matching rewrite rules?
- how do i remove posts from a WP_Query so the pagination is right?
- Saving Custom Post types and fields to a custom table
- dynamically generating plugin syntax
- Menus, but not by theme location
- Is it possible to use WordPress as an online portfolio for text content? What kind of theme would I look for?
- Building a store locator with google maps
- Duplicate posts when posting nulls in records in phpMyAdmin [closed]
- How to make wp_enqueue_style and wp_enqueue_script work only on custom post type
- Loco Translate: Custom Post and Custom Taxonomy Labels not translated in wp-admin menu
- How to make a customize role and view a specific plugins base on that role?
- Accessing post’s meta data based on user’s click of a post
- Update menu when saving settings
- custom post type not showing in menu
- Schedule Page to Menu [duplicate]
- How to create user groups and allow custom posts and plugin modify/access to specific group?
- Correct way to make meta box with more than one meta field secure
- I want to extend the current themes’ single.php to display the meta fields of my CPT
- Plugin custom post type – Internal server Error
- Exclude post by custom meta with pre_get_posts
- How can I create a custom shortcode that will return a custom post type by ID?
- Is it possible to create Custom Post plug-in?
- get_post_type() and WP_QUERY issue
- Using default WP menu functionality to link to custom post-type listing?
- get_post_type on post.php
- List taxonomy terms for post as checkboxes
- All of my custom posttypes are 404’ing
- more types plugin – display all post of post type on page
- When using Simple Fields plugin, how do I pull the information out of the database to display on a page?
- How to make a proper custom post type link
- Easiest way to add dropdown to a page
- Matching Chapters to a Custom posts [closed]
- How to get the element ID from new menu list that added with add_filter()?
- Custom post type – no layout section of Document tab, and no author choice
- Creating a custom post type, adding custom meta fields, preventing all future editability of posts of this type
- ‘No Results Found’ on single post for custom post type
- Keep a post copy when this one is updated – issue
- Making a Template for a CPT created by a plugin
- how to add a button next to the wordpress view button?
- auto populate list of questions if user select a category xyz
- Merging Two menus in the backend into one menu
- How to retrieve parent menu item name of current submenu item
- Delete mobile menu button [closed]
- html generated by theme exist but doesnt appear in browser
- Changing page URL and connect newsletter to MailChip
- Dynamic admin submenu
- Center and hide overflow of WP toolbar custom links
- Is there a way to establish parent/child relationship in WP menu links exclusively?
- Mq translate plugin custom post type issue
- Installing plugins and using complex folder structure with child theme in WordPress
- How to remove admin main menu name repetition
- “Custom Post Type Permalinks” plugin URL strcuture
- Unable to delete custom post types, confusion around capabilities
- Custom Permalink Plugin and Current Page/Ancestor in Menus
- wp-custom-menu filter removes the current_page_item class
- add_action does not call the function
- Adding CSS to custom post type admin page causes error
- get_the_title() gets printed out twice
- How to use my menu PHP code as sidebar?
- ACF: post query, hide duplicate values [closed]
- How to highlight 1st level menu item based on actual page
- What is the best way for showing a grid of customer logos?
- Custom Post Type Fields
- How to delete all trashed item in one-go
- How can I use a file in my plugin as a replacement for single.php on custom-post-type query?
- Custom setup of wordpress comments that are displayed
- publish_post action doesn’t work
- Disable Individual Plugins (specifically in Custom Post Types) on a per-post basis?
- WordPress custom taxonomy not showing
- Using ACF default value to autoincrement a number field
- custom post type don’t appear in the home page
- Edit Permalink Structure For Custom Post Type or Modify .htaccess?
- Hide a Menu Item on Login
- How to get menu location in wp_update_nav_menu hook
- PHP script from functions php is loaded via admin-ajax to div…and the result is 0, not the desired content
- How to Resize the Custom Post Images?
- Amazon.com intergration with WordPress?
- How to set category correctly for a custom post created by a remote API call?
- Use current class method inside add_submenu_page()
- Sticky option for custom post types without using custom fields or plugins
- How to use template_include hook with form submission?
- Trying to add a page template for my custom post type from a plugin, but it will not display in the template dropdown unless file is in theme
- Why WP_Screeen doesn’t show all options with admin_body_class
- Progmatically adding menu links to the default (Top) or Footer menu
- Adding custom meta boxes to specified custom post type
- How do I make reusable content blocks for header and footer when using WordPress headless with another front-end?
- posts from multiple post types in one slider
- How do we update a custom file upload field with the Advanced Custom Field plugin?