You should change $parents[] to $parents in get_parents() function:
$parents = get_metadata('post', $post_id, WPKWP::$META_CHILD, false);
if ($parents !== FALSE && count($parents) > 0)
return $parents;
return false;
because get_metadata return array in this case. If the $post_id parameter is invalid, false is returned. If the meta value isn’t set, function return an empty array.
Therefore, $parents array always will contain one element – false, empty array or array with values. The condition count($parents) > 0 is always true.
Define variable $meta = null; before if (WPKWP::get_parent()). If condition is true then only local $meta variable (invisible in return line) is created.
You define function get_parents but in get_post_metadata() you have WPKWP::get_parent().
Related Posts:
- How to make an meta_query optional?
- How to update single value in multi dimensional Post Meta?
- Modern Tribe Calendar wp-query with meta query not working at all
- Sortable admin column for one meta key with three possible meta values
- How to display custom field on homepage
- Can an array be used as a meta_query value?
- List of posts by day of the week
- WP Query with custom Shortcode
- Advanced Meta Query for Large Calendar Website (12k+ posts) (175k+ wp_postmeta rows)
- WP_Query Check if post has one or more attached medias
- Custom query, checking values of multiple meta keys
- Archive post by meta value + 24hours
- get_users meta_query: REGEXP not working for matching new lines
- Is it possible to retrieve all posts with a certain value for metadata?
- Grouping posts by a custom meta value
- Omit custom post type from wp-sitemap.xml based on meta key using wp_sitemaps_posts_query_args
- WP_Query: getting posts where custom field exists
- User Meta Value not echoing despite Var_Dump Showing correct string
- How to hide posts of a specific custom category in WordPress?
- Passing an array into WP_Query as a variable
- WordPress meta_query >= &
- How do I remove duplicate users from two merged WP_User_Query objects?
- Isn’t Returning Value While Using SELECT COUNT(*) FROM {$wpdb->prefix}
- How to sort WooCommerce products page by latest in-stock items first?
- Is it possible to order posts using multiple meta queries, i.e. show posts from first meta query, then the second?
- wp_Query with mutuplea values returns all posts
- meta_query search names when they have middle initials
- Usermeta data unserialize, extract and display in table in WordPress
- Meta query not showing result properly
- Filter loop by ‘price’ with meta_query
- WP_query meta_query slow with OR and DATES
- Get meta_query value by user meta array
- How to use something like meta_query but for fields?
- Efficient way of querying for a “fallback” post?
- Too many if’s and else if’s ?? – Must be better way [closed]
- get second ID from array
- How to check if feed URL was requested?
- How to return a string that has a variable inside in a shortcode?
- Cleanest/Fastest way to avoid calling and retrieving data from the database multiple times?
- Saving metabox repeatable fields
- Targeting single page with JS
- Remove General Tab and Plugin Tab in Settings in Woocommerce
- How to group 2 radio buttons in a widget?
- Missing sidebar parameter “fix” – before_content
- Don’t insert if permalink is the same?
- PHP errors in class-wp-query
- Store a default value for a transient on plugin activation
- How can I make an object available through the entire site?
- WordPress admin-ajax.php
- Update a buggy installation
- Error – ‘create_function is deprecated’ [closed]
- How to pass a PHP $_GET variable and fetch/output it?
- ACF put a comma after the last repeater field value [closed]
- parsing nested blocks (in columns, etc) via PHP
- Show ACF field with link to ultimate member profile/WordPress user profile below the post (single post layout)
- How to return a string that has a jQuery and Ajax inside in a shortcode?
- How to get a list of users who like a current wordpress post [closed]
- ‘pre_user_query’ interfering with user export
- Custom CSV exporter – Cannot modify header information – headers
- Custom post type url Rewrite (conflicting with page url)
- WordPress custom taxonomy
- pagination broken – clicking next displays “page not found”
- How to decrease the max file upload size without using php.ini or htaccess?
- How to check post meta isset or not empty during publish/save post?
- Nav Walker that shows only children and siblings of top level parent menu item
- Add posts to custom table in database instead of wp_posts
- Hide Approved status for certain users in users list
- Warning: urlencode() expects parameter 1 to be string, array given in /wp-includes/formatting.php on line 5343
- Constant expression contains invalid operations plugin class properties visibility
- How do I create a WP endpoint that retrieves all custom post types that have a tag?
- Adding a LISTING of PHP code in a page/post [closed]
- Static Page with php echo [duplicate]
- Show different button text if no content
- Displaying Children of several pages
- How do I fetch a data from an external database into my wordpress homepage
- Error when saving wordpress
- Position a repeated article blocks
- How to replace hard-coded list of custom taxonomy terms based on custom field query [closed]
- Only display notification on single post
- Add a downloaded JS file to WordPress
- Add options to WordPress backend
- Querying latitude and longitude into google maps correctly
- apply_filters() function
- How to define Og Meta Tags in header using conditions [duplicate]
- Changed URl in General Settings now WordPress site doesnt work
- Using tag to output text in Genesis?
- images in wordpress themes
- How do you get a reference to $wpdb in a PHP script
- Custom Registration and Login Forms with reCaptcha 2 Validation
- Change Checkout “Place Order” text if cart has a specific product
- php inside HTML via shortcode? [closed]
- How can I get is_page(Current_URL)?
- Error resetting database index using ALTER TABLE in $wpdb->query
- 500 Internal Server Error PHP 8.1 Array with wordpress
- why css file not link?how to create permalink?
- How to add different menu items on different menus?
- To perform the requested action, WordPress needs to access your web server
- Modify the permalink structure for a specific category
- “Joined in” or “Member since” displayed on single store page and then using shortcode to add
- AND and OR in my CPT search query depending on checkbox