Show posts by quarter

Let’s define a helper function to map a month to a quarter: function wpse_get_month2quarter( $month ) { return ceil( $month / 3 ); } We could then consider what to do with input values that are not integers in the set {1, …, 12}. ps: I got the idea for the formula from this Excel … Read more

Two Sections on Woocommerce Catergory Page [closed]

You have copy the archive-product.php in your template folder in the woocomerce folder. Then you edit the file and basically run a loop trough the catgeories you want (for example you category id’s are 12 and 24); $product_categories = array(12,24); foreach($product_categories as $category){ $product_options = array( ‘posts_per_page’ => -1, ‘post_type’ => ‘product’, ‘orderby’ => ‘menu_order’, … Read more

Remove any product that is featured from regular display loop [WooCommerce]

Use the pre_get_posts filter to remove your sticked product from the product loop. add_action( ‘pre_get_posts’, ‘exclude_stycky_product’ ); function exclude_sticky_product(){ // target only the main query if ( ! is_admin() && $query->is_main_query() ) { $query->set(‘ignore_sticky_posts’); $query->set(‘meta_value’, ‘1’); } } Hope it helps you !

loop inside the foreach

Finally, I figure it out. It seems that the get_posts and query_posts accept different arguments, when I use the get_posts I can setup the arguments like this: get_posts(array( “category” => $cate->term_id, “numberposts” => 12 )); While when I use query_posts I have change that to: query_posts(array( “cat” => $cate->term_id, “numberposts” => 12 )); Notice the … Read more

Loop through custom taxanomy in post and display custom fields from posts

You are going to need set up a new WP_Query in your content-*.php with the correct parameters in order to send it into a loop. <?php $args = array( ‘tax_query’ => array( array( ‘taxonomy’ => ‘recipes’,. ‘field’ => ‘slug’, ‘terms’ => ‘dessert’ ))); $your_posts = new WP_Query( $args ); ?> You can add any other … Read more

How to create a widget like this?

Your question is a little short on detail, but let’s suppose you have retrieved the posts using wp_query and are looping through it like this: $the_query = new WP_Query( $args ); if ( $the_query->have_posts() ) { while ( $the_query->have_posts() ) { $the_query->the_post(); STUFF } wp_reset_postdata(); } In the position of STUFF you want to distinguish … Read more