New answers tagged

0

The advanced custom fields plugin will probably do what you need. You can add field values to page templates using the plugins PHP functions


0

use below code to get user by role global $wpdb; $blog_id = get_current_blog_id(); $user_query = new WP_User_Query( array( 'meta_query' => array( 'relation' => 'OR', array( 'key' => $wpdb->get_blog_prefix( $blog_id ) . 'capabilities', 'value' => 'customer', //change your user role here which you want to display 'compare' => 'like' ), array(...


1

@CynthiaLara I suppose that you are using a container of WP_USER_QUERY::__construct in the form or WP_USER_QUERY or get_users or something to that effect. You can use 'meta_key' => '<YOUR_DESIGNATION_META_KEY>','orderby' => 'meta_value_num, to get results sorted by your meta key's value. If you have used a texted based value in for this ...


0

I could not get the @Mat solution to work. It looks correct, however. WP stores the value of $post->post_author as a string. However, get_the_author_meta( 'ID' ) and get_current_user_id() each return an integer, so strict comparison works in the second part of the IF statement. If you replace get_the_author_meta( 'ID' ) with $post->post_author you must ...


0

You’re almost there. Here’s the part that is setting the author of post to user with ID = 1: 'post_author' => 1, 'post_status' => 'publish', 'post_type' => 'testimonial', 'author' => $current_user->ID, You even try to set the author to $current_user, but you don’t initiate this variable anywhere in your code and you set ...


0

Not sure if you're looking for an "automated" way of doing this, but in code you can get an array of all co-authors by using $authors = get_coauthors();. Once you have your authors array, you can loop through it and use each author object's ID to get posts by that author: $authors = get_coauthors(); foreach ( $authors as $author ) { $args = array( '...


0

Custom Post Types will be much easier to set up, and you won't have to code your own solution to check in the Editor whether the current user has permission to create a new page or edit something. You can set up the CPT archives at whatever URL you like. So, in your example, you can set up a regular Page at /animals/ and a regular child Page at /animals/...


Top 50 recent answers are included