Different Results with query(‘s=computer’) vs get_posts(‘s=computer’)?

The default arguments for get_posts() function include ‘numberposts’ => 5. So if you’re querying for a search term that returns more than five (5) results the second query will return a maximum value of 5 unless you pass ‘s=computer&numberposts=-1′ as your query string. The WP_Query object doesn’t have a ‘numberposts’ default, although it is affected … Read more

Revolution Slider Orderby Two Custom Fields

To order by event-end date or start date, your write separate function and call them as per requirement. For example if user clicks on order by start then start function should be called. switch($orderby){ case: ‘event-start’: # your code /* $query[‘meta_key’] = ‘event_start_date’; $query[‘orderby’] = ‘event_start_date’; */ break; case ‘event-end’: #your code /* $query[‘meta_key’] = … Read more

Reduce Database Queries in Code [duplicate]

Because this is very similar to How to reduce the database query-es I will then give you an outline of a possible solution: You have four similar loops with 1) 1 post && offset=0 2) 4 posts && offset=1 3) 5 posts && offset=1 4) 6 posts && offset=1 so your main query will be … Read more

WP_Query in a shortcode

When you are constructing the $output variable, you need to consider get_the_post_thumbnail() get_the_excerpt() get_the_content() get_permalink() that return the values instead of the_post_thumbnail() the_excerpt() the_content() the_permalink() that echo the values.

What should I use, get_posts or wp_query for less CPU load?

I doubt using get_posts() vs WP_Query() would make any meaningful/noticeable difference in CPU load. Ultimately, get_posts() is just a wrapper for WP_Query(), anyway: $get_posts = new WP_Query; return $get_posts->query($r); You would be better served by looking at the efficiency of the queries themselves; but to provide specific assistance there, we would need to see each … Read more

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