How to array only one key from another array
Try this : // This converts the WP_Term Object to array. $catlist = json_decode(json_encode($catlist),true); $category_id = array_column($catlist, ‘cat_ID’); print_r($category_id);
Try this : // This converts the WP_Term Object to array. $catlist = json_decode(json_encode($catlist),true); $category_id = array_column($catlist, ‘cat_ID’); print_r($category_id);
Try this Omer $fields = array( ‘author’ => ‘<div class=”form-group”><input class=”form-control” id=”author” name=”author” type=”text” placeholder=”Name ‘.( $req ? ‘*’ : ” ) .'” value=”‘ . esc_attr( $commenter[‘comment_author’] ) . ‘” ‘ . $aria_req . ‘ /></div>’, ’email’ => ‘<div class=”form-group”><input class=”form-control” id=”email” name=”email” type=”text” placeholder=”E-mail ‘.( $req ? ‘*’ : ” ) .'” value=”‘ . … Read more
get_user_meta returns an array, so to get an array containing an array of each user’s data, use [] to append: foreach( $users as $user ){ $veik[] = get_user_meta( $user->ID ); }
If you check the line from the error notice you should find in WP 4.9.1 the usage of the function array_filter, that need a array as parameter (see the code). Your value inside your array for an post need an array for ‘post_category’, is currently a string. From the source of the WP core: * … Read more
If you’re asking how to get those meta keys via WordPress, you can use the get_user_meta() – https://codex.wordpress.org/Function_Reference/get_user_meta get_user_meta( $user_id, ‘tskypeid’, true )
The arguments for in_array() are the wrong way round. Looking at the documentation you can see that the first argument is the value you want to check (the ‘needle’) and the second argument is the array you want to check for it in (the ‘haystack’). So this means it’s always evaluating as false, meaning that … Read more
That is because you are passing false as the third parameter, that means you are retrieving all of the meta with the same key. The first time you store the value, the meta doesn’t exist and the value is stored into the DB as a string, the second time you store the value serialized that … Read more
Replace ‘call_user_func_array’ with name of the function to be called to output the page content. add_action(‘admin_menu’, ‘personalised_menu’); function personalised_menu() { add_menu_page( ‘Page Title’, ‘Blog’, ‘edit_posts’, ‘menu_slug’, ‘display_main_page’, ‘dashicons-welcome-write-blog’ ); add_submenu_page( ‘menu_slug’, ‘Add New Page’, ‘Add New’, ‘edit_posts’,’add_new_page’, ‘display_secondary_page’ ); } function display_main_page() { echo ‘Content of “Page Title”‘; } function display_secondary_page() { echo ‘Content of … Read more
<?php // query for your post type $post_type_query = new WP_Query( array ( ‘post_type’ => ‘pelicula’, ‘posts_per_page’ => -1 ) ); // we need the array of posts $posts_array = $post_type_query->posts; // create a list with needed information // the key equals the ID, the value is the post_title $post_title_array = wp_list_pluck( $posts_array, ‘post_title’, ‘ID’ … Read more
If I understand it properly, You can use the post__in parameter to query for specific posts where the post ID is in that parameter: $ids = [ 1, 2, 3, 4, 5 ]; $query = new WP_Query( array( ‘post__in’ => $ids, // … other args, if any. ) ); // Then loop through the posts. … Read more