There’s wp_list_pluck()
to get certain fields out of arrays or objects:
$object = new StdClass();
$object->foo = 'Hi!';
$object->bar="Yo!";
$array['foo'] = 'Hi!';
$array['bar'] = 'Yo!';
$result_obj = wp_list_pluck( $object, 'foo' );
var_dump( $result_obj );
// Result:
string (3) Hi!
$result_array = wp_list_pluck( $array, 'bar' );
var_dump( $result_array );
// Result:
string (3) Yo!
Related Posts:
- How to store the_title() into a variable to reutrn the value, not just echo it
- Need to get specific data from array
- Create an array from an array
- Check if term object is in array
- get a simple array of all of the term names that exist in all taxonomies
- Populate dropdown with Child Pages based on Parent Page chosen
- foreach loop still echoes array
- Checking array against author id in loop
- Alter required message using comment form api
- meaning of (array)function()
- Grouping posts by a custom meta value
- wp_force_remove_style’ not found
- How to fix this warning:call_user_func_array() expects exactly 2 parameters, 1 given in D:\wamp\www\…….\wp-includes\class-wp-hook.php on line 286
- Filtering a function’ output for a new continued function
- Warning: in_array() null given in PHP function
- Loop over Array and get the distinct ids
- If Array Values Match Another Array’s Values, Then
- Only load certain artists on this page
- How to make sure relative URL works when site is not on root domain?
- Custom functions for string data calculations
- Store custom field’s multiple values in one user meta key
- Fatal error when using array_diff() function inside of wp_update_nav_menu hook?
- Display posts using post ID’s in an array
- Page returning ID from array, how to return the correct values for post in acf wordpress
- Display a post based on its metabox selection
- Showing all post from all post type in admin backstage
- Custom WordPress Function – Adding items from Foreach Loop into an array and Updating Field based on array of IDs (ACF + WooCommerce)
- Replace block content with an array
- PHP – redirect https to http and www to non-www
- WordPress Infinite Scroll without using any plugin
- How to overwrite youtube embed?
- How to add SVG icon above product tab title
- Generating add_settings_section() calls dynamically
- Sort registered users by post count? (inside admin dashboard)
- Remove query string specific key value
- is_page “range” for if statement?
- Query all posts of a custom taxonomy term
- WordPress child theme fails to override parent navigation menu in /inc/structure/header.php
- Converting HTML Template to WordPress Theme
- Error when adding excerpt to the content through functions.php
- Add data attribute to each li in menu
- Prev/Next child navigation for current page modifications?
- Adding rel tag to all external links
- How can I apply_filters from inside a function?
- How to abort saving data in save_extra_profile_fields function WordPress?
- Populate editor with some content of a page with a page template
- I want to load in a new class but only if the current page is single-movies.php
- Skt full width basic slideshow problem
- Way to add captions to gallery images by code
- WordPress Options Page Theory Question
- How to make container class in PHP
- How to create an ACF shortcode with Repeater Field in WordPress? [duplicate]
- How to show/hide php table rows based on the content of custom fields
- How to call multiple functions from multiple files into a WordPress page template [closed]
- Prev/Next Links Broken on Static Front Page Pagination
- Reading settings in the home page precisely home.php
- Calling function in loop causes repeat data
- How can I split my query result in 2 arrays?
- Missing a text-domain esc_attr_e
- Is there a hack for using is_page() within the function.php file?
- Extract and display user infromation on an automatically created page
- Using multiple variables to assign categories to an array
- Programmatically revert to backup .htaccess a possibility?
- Execute PHP code only with specific user role
- Repeat a function with 24hrs gap for n number of days
- WordPress User Meta value variable into Google Gauge Chart
- Show all people who commented on all posts by an author
- PHP function for horizontal Woocommerce thumbnails and badges
- Custom global variable not working in function
- Embed video from streamtape using direct link
- Is there a PHP function that will return the block ID generated by WordPress?
- Creating a Function and Call It
- WooCommerce display price before add to cart [closed]
- Show sidebar only to author of post
- how to add custom select field to wordpress edit page
- Check if post visited first time
- WP post meta – for loop inside for loop
- Theme editing “post thumbnail” help
- Restrict File Type Uploads by User on Wordress via functions.php
- How to Request a User to Register on Landing at a Site, Then Automatically Delete the Users Password on Logout?
- Matching multi user
- AJAX Returning Way Too Many Posts
- Where can I find the declaration of `$_wp_theme_features`?
- redirect 301 with special character like WIX site “#!”
- auto metakey value on post tile
- How do I routinely extract the thumbnail of the most recent post?
- How I can add div to menu?
- Modify category archive page loop on functions.php
- How to print redirected query string variables to the page?
- Admin-area broken through weird issues
- Check if values exists DB
- Adapting a php array to WordPress
- How to combine array info [closed]
- Select area and checkbox data is not saving?
- How to modify this function to exclude also the post belonging to a specific category?
- Suppress errors when using global function
- Understanding responsive imagery
- How to get meta box labels?
- How to group by column a and sum column b and c in a php array
- Tags being Inserted in html from plugin PHP not passing through the_content