function query_posts disabling current_page_menu class

The issue is caused by the query_posts function, this function alters the global $wp_query which the menu walker uses to check and add classes like current_page_menu to menu items. A solution would be to write a new custom query and loop through that than using query_posts. $title_slug = strtolower(str_replace( ” “, “-” , the_title_attribute(‘echo=0’) ) … Read more

WordPress post filter menu

1- To get a list of authors, you can use: <?php wp_list_authors( ); ?> This will return a list of authors and a link to their accounts and posts. To customize it using your desired arguments, take a look at Codex 2- To retrieve the categories, use: <?php wp_list_categories(); ?> This function will return a … Read more

Posts from a category on homepage with category archieves page default css

$args = array( ‘posts_per_page’ => 5, ‘cat’ => 77 // 77 – id category ); $query = new WP_Query( $args ); // loop if ( $query->have_posts() ) { while ( $query->have_posts() ) { $query->the_post(); echo ‘<li>’; the_post_thumbnail(); echo ‘<a href=”‘.get_permalink().'”>’ . get_the_title() . ‘</a></li>’; } } else { // posts not fount echo ‘posts not … Read more

Random posts that always include a particular post?

Try this code:: post__in (array) – use post ids. Specify posts to retrieve. ATTENTION If you use sticky posts, they will be included (prepended!) in the posts you retrieve whether you want it or not. <?php $parent = $post->ID; $paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1; $query_args = array( ‘post_type’ => ‘page’, ‘post_in’ => array(‘post_id_to_include’), … Read more

How do I add a relation parameter to my filter query?

Each of your code blocks will overwrite the previous, you need to add to the array rather than replace it: $args[‘tax_query’][] = array( ‘taxonomy’ => ‘region’, ‘field’ => ‘id’, ‘terms’ => $_POST[‘region_filter’] ); relation is AND by default, so you can just omit it, but if you wanted to explicitly set it: $args[‘tax_query’][‘relation’] = ‘AND’;

Get post by tag

Look at this section: Tag parameters in WP Codex, where is explained search by tags. Your code like right. Try change numberposts to int: <?php $args = array( ‘numberposts’ => 3, ‘post_status’ => ‘publish’, ‘tag’ => ‘travel’ );

How can I comment comma-separated array values?

No, it’s definitely not okay to comment your code this way. It changes the string, and even though WordPress might strip the incorrect characters and yield the correct pages (it wouldn’t if your “comments” contained comma’s or numbers), it is incredibly unstable. Instead, if you do want to comment them, I would suggest storing them … Read more

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