Huge amount of queries on my site
I would bet my bottom $ that the permalinks are the problem, your link shows a heck of a lot wp_rewrite queries.. take a look at this a similar issue
I would bet my bottom $ that the permalinks are the problem, your link shows a heck of a lot wp_rewrite queries.. take a look at this a similar issue
Check if this solution work for your case: add_filter(‘posts_request’, ‘supress_main_query’, 10, 2); function supress_main_query( $request, $query ){ if( $query->is_main_query() && ! $query->is_admin ) return false; else return $request; } posts_request is the last filter called before running the query, and pass to you the $requestvariable with the generated SQL string and $query, with the WP_query … Read more
An easy way is to use a static variable to store author name, then run again same function on a later hook, maybe ‘posts_results’ and set back the variable: function wpquery( $query, $query_on_results = NULL ) { static $author_name = NULL; if ( current_filter() === ‘pre_get_posts’ ) { if ( $query->is_author() && $query->is_main_query() ) { … Read more
Use like this query_posts( array( ‘category__in’ => array(5,1), ‘posts_per_page’ => 1, ‘orderby’ => ‘title’, ‘order’ => ‘ASC’ ) ); or $my_query = new WP_query(array(‘category__and’ => array(5,1))); while ($my_query->have_posts()) : $my_query->the_post();
You are correct, you will need to get the image URL and set is as a variable so you can echo it out as an inline style in your HTML. I’ve updated your foreach loop below and set the image as an inline style of your <li> element: foreach( $postQuery as $post ) : setup_postdata($post); … Read more
Making Milos’s comment into an answer…. The problem you are facing is the result of many wordpress template oriented functions expect some global variables. In WP_Query based loops setting those variable is done by calling the the_post() method of the WP_Query object, but with get_posts you need to call setup_postdata() for that. My personal preference … Read more
The $wpdb object is part of WordPress, so wouldn’t be loaded into a standalone PHP page as it is into a WordPress template. You might want to look into creating your own page templates, then you could run your database query as part of that page template. As a side note: You are currently trusting … Read more
The date format is incorrect. I’m not sure how you have stored the date, but the format you’ve used in the query, date(“MM d yy”) outputs ‘MarMar 07 1212’. It shouldn’t really matter that the input is being done by jQuery datepicker: The input should be in a pre-specified format – so you can interpret … Read more
Zlatev meta_key is the name of the custom post type, and is a VARCHAR(255) meta_value is the value of the key, and is a longtext With your query you are not ordering by values, but by the name of the field. The query works for _thumbnail_id because you are using LEFT JOIN and the CPT … Read more
This should do the trick for you. This shows what template file is stored in post_meta, if one has been selected in the admin panel: $template_name = get_post_meta( $the_query->post->ID, ‘_wp_page_template’, true ); If you want to see if the page is the homepage, use is_home() or is_front_page(). If you want to see what files are … Read more