Some images not being returned with wp_get_attachment_image
Some images not being returned with wp_get_attachment_image
Some images not being returned with wp_get_attachment_image
Pagination with WP_Query not working
I managed to solve this by taking s_ha_dum’s suggestion to use a UNION. It is as follows: (SELECT ID, post_status, post_title, post_excerpt, post_content FROM wp_posts WHERE ((`post_title` LIKE ‘%diamond%’) OR (`post_excerpt` LIKE ‘%diamond%’) OR (`post_content` LIKE ‘%diamond%’)) AND (`post_status` = ‘publish’ )) UNION (SELECT ref, StoreID, Article, subarticle, description FROM wp_hwproducts WHERE (`article` LIKE ‘%diamond%’) … Read more
Perhaps check to see within the first loop if its paged or not based on the value you set for the ‘posts per page’ arguments. If not paged show the results via your template, if it is paged, then do nothing… //First Loop if ( $query1->have_posts() ) { while ( $query1->have_posts() ) { $query1->the_post();?> <?php … Read more
I would do something like this: <?php //Protect against arbitrary paged values $paged = ( get_query_var( ‘paged’ ) ) ? absint( get_query_var( ‘paged’ ) ) : 1; $args = array( ‘posts_per_page’ => 6, ‘category_name’ => ‘case-study’, ‘paged’ => $paged, ‘show_all’ => False, ‘prev_next’ => True ); $the_query = new WP_Query( $args ); ?> <?php if … Read more
My blog has over 700,000 articles… You need to look at your webhost and server. WordPress is perfectly scalable, but you need the hardware to back it up. That’s a database intensive query, and you need the MySQL server to handle it. Run mysqltuner.pl https://github.com/major/MySQLTuner-perl to check your MySQL configurations and adjust cache and memory … Read more
wp_query display posts based on day
The snippet below from the codex suggest that it would just display the first sticky post. If there are none, it wont return anything. Whatever your use case is please apply the logic accordingly. $sticky = get_option( ‘sticky_posts’ ); $args = array( ‘posts_per_page’ => 1, ‘post__in’ => $sticky, ‘ignore_sticky_posts’ => 1 ); $query = new … Read more
Set right order for query that returns posts based on two custom fields
The problem with this, as it often is, is not just homepage, but the continuous nature of pagination. Let’s say we start with 10 posts on home page and 5 of them social. Client says that they would like 2 less of social. We can get rid of them easily enough, but now we need … Read more