Display only the latest post

Your query arguments, formatted to be readable, look like this: $args = array( ‘taxonomy’ => $taxonomy, ‘term’ => $term->slug, ‘posts_per_page’ => 1, ‘orderby’ => ‘modified’, ‘category’ => $str ); That does not match any argument pattern I see for WP_Query. I think you are trying to construct a tax_query but that should look like this: … Read more

modify stylesheet of a particular page inside wp-admin

Do not modify the edit.php file directly as modifying WordPress core files are not recommended and may generate new issues, will get overwritten when WordPress is updated. Instead you can use properties and functions of WP_List_Table class to change it, along with adding css to backend for design changes.

update_user_meta on registration but only for default role type

Here is what you need to do: function set_user_rcp_default_subscriber($user_id) { $user = new WP_User( $user_id ); foreach( $user->roles as $role ) { if ( $role === ‘subscriber’ ) { update_user_meta( $user_id, ‘wp_user_level’, ‘0’ ); update_user_meta( $user_id, ‘rcp_subscription_level’, ‘1’ ); update_user_meta( $user_id, ‘rcp_status’, ‘active’ ); update_user_meta( $user_id, ‘rcp_expiration’, ‘2014-06-30’ ); } } } add_action(“user_register”, “set_user_rcp_default_subscriber”, 10, … Read more

Sort Posts Alphabetically by Multiple Categories [duplicate]

Use the orderby and order parameters in the argument list. See the Orderby_Parameters section of WP_Query for details. $category_ids = $arr_records = $post_data = array(); $categories = get_categories( ‘child_of=4’ ); foreach( $categories as $category ) { $category_ids[] = $category->term_id; } $post_data = get_posts( array( ‘cat’ => $category_ids, ‘orderby’ => ‘title’, ‘order’ => ‘ASC’, ) ); … Read more