query_posts result differs from wp_query request result

You are improperly using query_posts. Don’t use query_posts, ever. If you want to iterate over an array of posts, use get_posts and assign the results to a var that isn’t a reserved global. $my_posts = get_posts( array( ‘posts_per_page’ => 5, ‘paged’ => 1, ‘post_status’ => ‘publish’ ‘orderby’ => ‘date’, ‘order’ => ‘desc’ ) ); foreach( … Read more

wp_query by last month + sort posts

The recent addition of date query makes it possible to use very elaborate conditions, see Date Parameters documentation in Codex. As for outputting certain set of posts the simplest way might be to create dedicated page with custom page template for it.

Show previous month’s posts

This could be a simple PHP issue of how you are asking to return the first date() date(‘M’, mktime(0, 0, 0, date(‘m’), 0, date(‘Y’))); is returning Dec, and WP_Query needs the month number. First, try changing ‘M’ to ‘m’. date(‘m’, mktime(0, 0, 0, date(‘m’), 0, date(‘Y’))); If that doesn’t work, try using the date_query and … Read more

Custom query posts error

When you do this: $querystr = “SELECT * FROM `wp_posts` WHERE post_content LIKE ‘%Alba%’ AND post_type=”post” OR LOWER(post_title) LIKE ‘%$nume_searchq%’ OR LOWER(post_content) LIKE ‘%$spec_searchq%’ OR LOWER(post_content) LIKE ‘%$instit_searchq%’ LIMIT $limit “; If ANY of the variables are blank ($nume_searchq || $spec_searchq || $instit_searchq ), you will get all posts, because LIKE ‘%%’ matches everything. So … Read more

No duplicate tags by category

I did something similar in the past project and this is my solution. I hope this is what you want. <ul class=”inline-list”> <?php query_posts(‘category_name=lain-lain’); if (have_posts()) : while (have_posts()) : the_post(); if ( get_the_tag_list() ) : $count = 0; foreach ( get_tags() as $value ) { if ( $count>=10 ) break; $output .= ‘<li><a href=”http://example.com/tag/’.strtolower( … Read more

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