Retrieve only posts from a specific user in wp-admin/edit.php

You will need to filter that list. function alter_views_wpse_103613($views) { $role=”blogger_simple”; if (current_user_can($role)) { $views = array(‘mine’=>$views[‘mine’]); } return $views; } add_filter( ‘views_edit-post’, ‘alter_views_wpse_103613’ ); That filter list is part of the WP_List_Table class if you want to investigate more. Look for the views method.

do more action after I publish a post

There are a number of hooks you can use, such as publish_post or save_post, e.g.: // an example of a post save hook add_action( ‘save_post’, ‘diligents_post_save_hook’ ); function diligents_post_save_hook( $post_id ) { //verify post is not a revision if ( !wp_is_post_revision( $post_id ) ) { // do things } } save_post will fire on publish … Read more

Advanced WP Query and/or

I am not 100% sure what you are asking but as written that is going to be wrong. tax_query is an array of arrays but you have an array of array of arrays. You create the third array when you put $taxQuery into array($taxQuery). This should be more correct: $args = array( ‘post_type’ => $postType, … Read more

While loop articles – if statement order

Prepare the query before you loop over it: $first = array_shift( $the_query->posts ); $second = array_shift( $the_query->posts ); // now re-add in reverse order array_unshift( $the_query->posts, $first ); array_unshift( $the_query->posts, $second ); // this is now the first item while ($the_query -> have_posts()) : $the_query -> the_post(); // regular loop

How do I query_posts in cat=1 AND not in cat=2

First, never use query_posts, use WP_Query for additional queries, or pre_get_posts to alter the main query. Refer to WP_Query in Codex for a complete list of available arguments. You want to use category__not_in in this case: $args = array( ‘category__in’ => array(1), ‘category__not_in’ => array(2) ); $query = new WP_Query( $args );

Set colors depending on category

Setting aside that you’re incorrectly using query_posts(), the easiest solution is to add a call to post_class(), to output post-specific classes, including .category-{ID} and .category-{slug}: <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?> <li <?php post_class(); ?>><a href=”https://wordpress.stackexchange.com/questions/123066/<?php the_permalink(); ?>” title=”<?php the_title(); ?>”><strong><?php the_title(); ?></strong></a><br /> <em><?php echo substr(get_the_excerpt(), 0,110); ?> … Read more

How to show only the most recent post on my custom post type archive?

You could just alter the main query for your custom post type archive with pre_get_posts(). Code: function wpse124228_alter_ppp_order_for_mycpt( $query ) { if ( ! $query->is_main_query() || is_admin() ) return; if ( is_post_type_archive( ‘mycpt’ ) ) { //Only display 1 post on mycpt archive $query->set( ‘posts_per_page’, 1 ); //Most recent/current $query->set( ‘orderby’, ‘date’ ); $query->set( ‘order’, … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)