Is `query_posts` really slower than secondary query?

You ask: is query_posts really slower than some secondary query… The fact is that if you’re calling query_posts() from a theme then it already is a secondary query. WordPress has already queried the database once to get a certain page then it hits your query_posts() function and queries the database again creating a second query … Read more

is_home, and is_front_page conditional problem

Let’s see if I can confuse myself. If either of your two OR conditions is true the code executes. is_home and is_front_page can return true for different pages, negated in your case. If you have a static from page, which it sounds like you do, then is_home is the blog index page. Note: WordPress 2.1 … Read more

Custom Loop and Infinite Scroll

I used ‘init’ in the add_action in my own implementation of infinite scroll, try that. add_action( ‘init’, ‘vg_infinite_scroll_init’ ); As to your question about rendering a custom query you would do the following. -Set the render to your function name ‘render’ => ‘your_render_function, -Add your function to call a specified loop template function your_render_function(){ get_template_part( … Read more

Loop.php vs looping inside template file

Depends on whether you would use that single-loop in more places. If you’re only using it in one place and that will remain the case, do it within single.php, if you’re going to be reusing it elsewhere, I’d highly suggest using a single-loop template part.

save_post + insert_post = infinite loop

This is because the first time you go round the loop $post is the current post. But the second time you go around the loop, $post has not changed. The same thing happens the 3rd, 4th, 5th, etc Because the $post variable is the current post of that page, not the post you’ve just saved/inserted, … Read more

Get post by page name or slug

Hi @Zach Shallbetter: If I understand your question, then you are looking to solve your problem using theming functions when you really need to use more of WordPress’ API. The following code can be copied to a test.php file and run using http://yoursite.com/test.php for you to see how it works (assuming you replace http://yoursite.com with … Read more

How to get the first image gallery of a product in woocommerce in a loop

Along with the product thumbnail (I’m assuming you have this), what you need is a list (array) of the product images – WooCommerce has such methods, eg $product->get_gallery_attachment_ids(). You can grab the first ID in the array and use it to fetch the single image using wp_get_attachment_image(), or wp_get_attachment_url(), etc., then use that as an … Read more

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