Retrieve IDs from custom field, count and display results differently according to count

I answer to myself, since this code is working better (previous had an issue) and also I removed a useless “for”: echo ‘<ul class=”related-content”>’; $count = 0; foreach(get_field(‘related_content’) as $post_object) : $count++; if ($count > 0 && $count < 4 ) { printf(‘<li class=”large”><a target=”_blank” title=”‘.get_the_title($post_object->ID).'” href=”‘.get_permalink($post_object->ID).'”><span style=”display: block” title=”‘.get_the_title($post_object->ID).'”>’.get_the_post_thumbnail($post_object->ID, ‘small’).'</span><span class=”thumb-title”>’.get_the_title($post_object->ID).'</span></a></li>’); } elseif ($count … Read more

Please help me to win the battle with 2 column loop by category

You should not use query_posts more than one time. It will create errors. You have to use wp_query. Here is what it says in wordpress codex: query_posts( is meant for altering the main loop. Once you use query_posts(), your post-related global variables and template tags will be altered. Conditional tags that are called after you … Read more

Loop doesn’t work in single-product.php page but works at normal page

A part of the problem was that “caller_get_posts” is deprecated, it is now “ignore_sticky_posts”. The main problem was this line “$post_type = $wp->query_vars[“product”];”, i removed this one and replaced the $post_type with ‘product’. This code works! <?php $tax = ‘product_category’; $tax_terms = get_terms($tax,’hide_empty=0′); if (is_array($tax_terms)) { foreach ($tax_terms as $tax_term) { $args=array( ‘post_type’ => ‘product’, … Read more

WordPress loop: Display if posts exist

You can use the has_tag function in a conditional statement to achieve what you want. Take a look at the codex page here: Function Reference/has tag. This isn’t 100% tailored to your specific question, but you should see how it’s working and adjust for your specific task: <?php if( has_tag() ) { ?> <?php query_posts( … Read more

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