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

How to place a loop within another loop?

Try this: We declare an incrementer at the top of our outter loop called $popularLoop to keep track of how many popular loops we’ve been through, we assume we’re going to at least hit 1. Inside our Inner Loop (popular) we need to set how many posts per page we’re going to load, multiple that … 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

Executing Queries in tag.php

That’s because the main query is being discarded and replaced with your custom query. You’ve not told your custom query to look for that tag, so why would it? You might also notice your pagination is broken for the same reason, you’ve not told the new query which page you’re on, so why would it … Read more

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