The following code I wrote is supposed to show all the product categories of a wordpress ecommerce website.
<?php $categories = get_terms( array( 'taxonomy' => 'product_cat', 'hide_empty' => 'false', 'numberposts' => -1) ); ?> <?php var_dump($categories); ?> <?php foreach( $categories as $category ): ?> <h4 class="shop-category-name d-inline"><?php echo $category->name; ?></h4> <?php endforeach; ?>
I’m using it inside a woocommerce hook that is responsible to render the contents before the main shop page, the woocommerce_before_main_content
. I’m not able to get the categories, I will see only one category and the others are not listed. I’m not sure about, but maybe this can be something related to the fact that I’m using the function inside a woocommerce hook? I had a similar issue with the shop page featured image, I was not able to display it because of this motivation and I have modified the code to use the wc_get_page_ID('pag name')
.
Is there a fix ?
Related Posts:
- WooCommerce action hooks and overriding templates
- Add CashU payment gateway to WordPress Woocommerce
- WordPress Error: There has been a critical error on your website. Please check your site admin email inbox for instructions
- Prevent category updates in WordPress Woocommerce REST API
- Problem getting data with WooCommerce/WordPress
- Problem getting data with WooCommerce/WordPress
- Custom Coupon type woocommerce wordpress
- PHP fopen() Error: failed to open stream: Permission denied
- Woocommerce variable products: Sorry, this product is unavailable. Please choose a different combination
- Redirect after Login on WordPress
- Formidable Forms WordPress Plugin
- How to implement inline cm/inches conversion in WordPress
- Redirect old php link to wordpress link in .htaccess
- WordPress qw.php file on root of installation
- How to change thumbnails for WordPress pages (KakaoTalk)
- My UPS shipping method is not working in wordpress project
- Remove “Protected” text in title h1 of protected wordpress pages
- How to convert JPG to PNG on upload in WordPress (via add_image_size)?
- WordPress plugin install: Could not create directory
- WordPress makes an auto-draft as soon as I enter the page
- Using WordPress on 000webhost.com
- Display only one category on home page wordpress
- WordPress custom thumbnail size
- Php – Your PHP installation appears to be missing the MySQL extension which is required by WordPress
- Php – Your PHP installation appears to be missing the MySQL extension which is required by WordPress
- Local WordPress installation is stripping ‘wp-admin’ from URL on WordPress admin dashboard
- Advanced Custom Fields, Yoast SEO, not updating new values in WordPress
- WordPress sort WP ULike posts in custom query?
- WordPress (Woocommerce) order by Product Dimensions (Length, Width, and then Height)
- Exclude Featured Posts in WordPress ‘Recent Posts’ Function
- WordPress: How to overlay text / widget div on top of a revolution slider
- WordPress – add second logo to customizer
- php, cookies, wordpress – how to make automatic login in one one site, login and on other one
- How can I removed Powered by WordPress link in wp.login.php without editing core WP files?
- Woocommerce/WordPress BarclayCard Payment Gateway
- WordPress Login Tracking Google Analytics
- WordPress – Check if user is logged in
- WordPress custom supports for custom post types
- WordPress PHP proxy/helper pages for Twitter API
- How to enable button onClick functions and java script in wordpress post
- Marathi typing option in wordpress Editor
- WordPress: Loading multiple scripts with enqueue
- WordPress: Loading multiple scripts with enqueue
- Display all post meta keys and meta values of the same post ID in wordpress
- Query multiple WordPress post types alternately
- How to add custom javascript to WordPress Admin?
- With “magic quotes” disabled, why does PHP/WordPress continue to auto-escape my POST data?
- WordPress Email Share button not opening in Outlook
- After moving WordPress, login works, but no admin access anymore
- WordPress localhost not working
- validate textfield contents in wordpress simple job board plugin
- how to create a custom live search in WordPress from scratch
- Why am I getting 404 not found on this wordpress subdomain on my Nginx server?
- wordpress Simple Job board plugin hide cv attachment form
- How can I access http://localhost/wordpress/wp-admin/install.php?
- How can I access http://localhost/wordpress/wp-admin/install.php?
- Dash icons Not Showing properly in Menu Using WordPress
- W3 Total Cache WordPress plugin disturbing my page layout
- No paged query var being set in WordPress custom pagination
- cannot change admin password, wordpress on godaddy
- WordPress Password Protected Page is not protected
- How do i give a WordPress editor access to the Site Kit by Google plugin?
- Permalinks in WordPress not working
- cannot change admin password, wordpress on godaddy
- cannot change admin password, wordpress on godaddy
- How to define custom capabilities in wordpress for custom plugin
- WordPress Order by date on custom post type archive page
- Divi Child Theme Breaks WordPress Customizer
- Get the WordPress attachment image url
- WordPress theme Flatsome 3.11: UX Builder not loading
- After migration of WordPress website I can’t access the admin (white page)
- Double slashes on WordPress Admin URL redirects to wp-login
- wordpress login wp-login.php change url
- Cant login to wp-admin (redirecting to homepage), But CAN login to wp-login.php
- Cant login to wp-admin (redirecting to homepage), But CAN login to wp-login.php
- WordPress: Login for Users Without access to wp-admin
- WordPress (GoDaddy: Linux w/cPanel (Apache))_ My 2nd site is FUBAR__ subdomain multisite network installation
- WordPress- url for localhost wp-admin is not working
- WordPress- url for localhost wp-admin is not working
- Muffin Builder has a limit? (WordPress – Be Theme)
- Display Ninja Forms Data in WordPress Template
- update post meta wordpress
- Get Categories of events in WordPress Events Calendar Pro Plugin
- Get Categories of events in WordPress Events Calendar Pro Plugin
- How can I add a PHP page to WordPress?
- How can I add a PHP page to WordPress?
- Why can’t import backup site WordPress? Plugin All-in-one migration
- How to correctly use get_template_directory_uri() WordPress function to load an image that is in a subfolder of my theme?
- Display all post meta keys and meta values of the same post ID in wordpress
- How can I configure the WordPress development environment locally?
- Error establishing a database connection in my localhost
- why are two paragraphs being added on wordpress custom excerpt function used?
- function “add_submenu_page in wordpress connects to the home page instead of the submenu page
- Add php code inside the function add_shortcode in functions.php WordPress
- Correct way of using wp_get_attachment_image() in wordpress
- How to cache/speed WordPress queries for logged in users?
- Page Redirection in WordPress
- Show comments on WordPress home page
- How to easily add cropped screenshot to self-hosted WordPress as hosted image?
- Which ways can be used to log in to WordPress?