Show post number in widget loop

It’s not clearly stated in your question, but I guess, you added exactly this code to the widget file: <?php echo $wp_query->current_post +1; ?> Am I right? If so, then it couldn’t work, because this code takes the counter from global $wp_query object, but… This widget doesn’t use global $wp_query and uses custom WP_Query instance. … Read more

Posts will not display on page-mypage.php

You can use custom query to show post in your template $args = array( ‘post_type’ => ‘product’, ‘posts_per_page’ => 10 ); $loop = new WP_Query( $args ); while ( $loop->have_posts() ) : $loop->the_post(); the_title(); the_content(); endwhile;

WordPress loop: exclude if it is the latest post

If you create your own queries for these loops, all you have to do is to use post__not_in param in these queries. This way you will exclude given post from these loops. And to get the ID of first post, just use get_posts with ‘fields’ => ‘ids’

Duplicated posts on category page

OK, so the code does exactly what it is supposed to. In your archive.php you do this: while ( have_posts() ) : the_post(); get_template_part( ‘loops/loop’, ‘archive’ ); So for every post (both of them) you include loops/loop-archive.php file. And inside that file you don’t display only the current post from global loop, but you make … Read more

A to Z List of Custom Post Type in three columns

The problem lies in this line: $rows[$count] = $rows[$count] . ‘<div class=”col-sm-3″>’ . ‘<h4>’.strtoupper(get_the_title()[0]).'</h4>’ .'<div class=”post-title”>’. ‘<li><a href=”‘.get_permalink().'”>’.get_the_title().'</a></li>’ . ‘</div></div>’; As I understand your code correctly, it should append another column item to given row. But it doesn’t do it – it overwrites the content of given row with current column. So it should look … Read more

Displaying Woocommerce Product Category in WordPress

woocommerce categories are not a “category” they’re the product_cat taxonomy. change your args like so: $params = array( ‘posts_per_page’ => 5, ‘post_type’ => ‘product’, ‘tax_query’ => array( array( ‘taxonomy’ => ‘product_cat’, ‘field’ => ‘slug’, ‘terms’ => ‘cap’ ) ) );