Filter posts/pages by user_role array

You’ve used LIKE comparison method, that means every similar expression will be matched, including exact string and similar string. If you want to match exact string, you should use = operator. Example: global $current_user; $user_roles = $current_user->roles; $user_role_query = array(); for ($i=0; $i < sizeof($user_roles); $i++) { $user_role_query[] = array( ‘key’=>’attribution_roles’, ‘value’ => $user_roles[$i], ‘compare’=>’=’ … Read more

WP_Query with Pagination and orderby meta_value_num showing duplicates

$paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1; $args = array( ‘tag’ => $taxonomy, ‘post_type’ => ‘initiative’, ‘paged’ => $paged, ‘posts_per_page’ => 9, ‘category_name’ => $category, ‘tag__not_in’ => array(15), ‘meta_key’ => ‘initative_weight’, ‘orderby’ => array(‘meta_value_num’ => ‘DESC’, ‘title’ => ‘ASC’), ‘post_status’ => ‘publish’ ); I changed tag__not_in to an array and updated the orderby to be … Read more

Showing Children of page by name

You need to pur div container before while loop. Here you go. Here is the modified code and container will have parent page slug class. <?php $args = array( ‘post_type’ => ‘page’, ‘posts_per_page’ => -1, ‘depth’ => 2, ‘sort_column’ => ‘post_name’, ‘post_parent’ => $post->ID, ‘order’ => ‘ASC’, ‘orderby’ => ‘menu_order’ ); $parent = new WP_Query( … Read more

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