Update wordpress menu with woocommerce products

EDIT: I tried the following and it works in the theme “Storefront for woocommerce”(Though it needs additional styling). For some reason though, it does not work well with the twentyfifteen theme.(The submenu does not show.) add_filter( ‘wp_nav_menu_items’, ‘wc_products_on_nav_menu’); //filter to add the html add_action( ‘save_post_product’, ‘rebuild_custom_wc_nav_menu’); //action to regenerate the menu array anytime a product … Read more

Echo Category In Loop

The function get_theme_mod() returns information. Since you want to assign it and not echo it to the screen, we can remove the echo and PHP tags: $args = array( ‘post_type’ => ‘product’, ‘stock’ => 1, ‘posts_per_page’ => 4, ‘product_cat’ => get_theme_mod( ‘vatname’, ‘Clothing’ ), ‘orderby’ =>’date’, ‘order’ => ‘ASC’ ); That should fix your query. … Read more

Why does my WordPress index has a category?

Well I havent found why there’s a category to my homepage but I found the function is_home() and added it to my if: if($category[0]->{‘name’} !== “Blog” || is_home()){ echo “document.onload = removeWhiteDiv();”; } if($category[0]->{‘name’} === “Blog” && !is_home()){ echo “headerAnimation();”; }

i want to add pagination list of categories

<?php $args = array( ‘parent’ => 0, ‘hide_empty’ => 0 ); $categories = get_categories( $args ); echo $cat = ceil(count( $categories )/5); ?> <?php $j=0; $paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1; $posts_per_page = 5; $offset = ($posts_per_page * $paged) – 5 ; $args = array( ‘orderby’ => ‘name’, ‘parent’ => 0, ‘hide_empty’ => 0, … Read more

Listing categories on a wordpress page

FOR : category display horizontally. This code put into the function.php file. Create a function for list of category. function category_name(){ $cat = get_terms(array(‘taxonomy’=>’category’)); echo ‘<div clss=”design”>’; foreach($cat as $ca){ echo ‘<span>’; echo $ca->name.’&nbsp&nbsp’; echo ‘</span>’; } echo ‘</div>’; } After put this code call the function echo category_name(); when you get the list of … Read more

Categories not shown on sidebar

As noted in the comments the issue here is that the sidebar was calling the_category(), which displays only the current category, rather than listing all categories. An even more “WP way” approach is to make the sidebar dynamic. That way, you can use widgets rather than hard-coding what appears in the sidebar. WP has a … Read more

Sorting Woocommerce products by category and attributes

Hi @ColinTravis you can use following function in functions.php : /** * Defines the criteria for sorting with options defined in the method below */ add_filter(‘woocommerce_get_catalog_ordering_args’, ‘custom_woocommerce_get_catalog_ordering_args’); function custom_woocommerce_get_catalog_ordering_args( $args ) { global $wp_query; // Changed the $_SESSION to $_GET if (isset($_GET[‘orderby’])) { // switch ($_GET[‘orderby’]) : // case ‘pa_pub-year’ : $args[‘order’] = ‘ASC’; //$args[‘meta_key’] … Read more

WooCommerce category display in custom page

You have to create a custom template for that. The template have to clone the content of taxonomy-product_cat.php, which thankfully is basically a single line. Your template will be something like this: <?php /** * Template Name: YOUR TEMPLATE NAME HERE */ // Set the parameters of your query $args = array( ‘post_type’ => ‘product’, … Read more