User rank in wordpress post

There is various approach you could take. All you need to do essentially is to get the author’s role and put it in a statement of sort. For example, let’s get the author role first by: // inside the loop $author_role = get_the_author_meta(‘roles’, $post->post_author); Then just use do a if statement like: if ($author_role == … Read more

Admin Post List Only Show One Category

I found a hacky solution involving redirecting the user: if ((basename($_SERVER[‘SCRIPT_NAME’]) == ‘edit.php’)) { // your code here $author = wp_get_current_user(); if(isset($author->roles[0])){ $current_role = $author->roles[0]; }else{ $current_role=”no_role”; } if($current_role == ‘ai1ec_event_assistant’ && ($_GET[‘post_type’]==”&&$_GET[‘category_name’]==”)){ header(“Location:/wp-admin/edit.php?category_name=events-list”); } }

Converting Posts to Pages

A while ago I added a function to one of my sites to change a set of posts from one type to another. I can’t remember exactly why, but I’ve dug it out and updated it a little, and it is tested and working. The function Place this in functions.php so that it can be … Read more

show latest authors blog post

Please Try This To Get Post in DESC order $args = array( ‘orderby’ => ‘title’, ‘order’ => ‘DESC’, ‘author’ =>’authorName’, ); $query = new WP_Query( $args ); // The Loop if ( $query ->have_posts() ) { echo ‘<ul>’; while ( $query ->have_posts() ) { $query ->the_post(); echo ‘<li>’ . get_the_title() . ‘</li>’; } echo ‘</ul>’; … Read more

How to display term in archive page?

Use wp_get_object_terms function to get any taxonomy you want, category, tag, state, etc. For example: $terms = wp_get_object_terms(get_the_ID(), ‘state’); $state = array_pop($terms); echo $state->name; This function is returning array of terms, so in case you only have one state, it will return array of one item in it.