The product title is added to the woocommerce_single_product_summary hook at priority 5, so you’ll want to add to the same hook with a lower (earlier) priority. You’d add this to your theme’s functions.php file. I presume when you say “category” you mean the WooCommerce product category, so this should return the first one and print it before the product title:
function wpa89819_wc_single_product(){
$product_cats = wp_get_post_terms( get_the_ID(), 'product_cat' );
if ( $product_cats && ! is_wp_error ( $product_cats ) ){
$single_cat = array_shift( $product_cats ); ?>
<h2 itemprop="name" class="product_category_title"><span><?php echo $single_cat->name; ?></span></h2>
<?php }
}
add_action( 'woocommerce_single_product_summary', 'wpa89819_wc_single_product', 2 );
Related Posts:
- Problems with autoloading classes via sp_autoload_register / maybe interfering WP-specific autoloader
- Advice on naming files for a plugin
- What is the correct way for a theme to support plugin UIs?
- What is the ‘admin_action_’ . $_REQUEST[‘action’] hook used for?
- How does WordPress determine the primary plugin PHP file?
- How should I use register_setting, add_settings_section, & add_settings_field in my plugin’s options page?
- Data sanitization escaping HTML apostrophes
- Custom comment type maybe?
- How do I get Version of all active plugins programmatically?
- Remove Adminstrator Hyperlink from a user having role to add and see users
- Enable comments for post with comments meta box removed
- How to link to YouTube videos with thumbnails?
- Problem protecting a page with a password
- Storing image gallery plugin data
- wordpress custom login successful redirect hook
- Is there any site where i can found good documentation of wp-ecommerce plugin?
- plugin for wp_list_categories with posts
- flush_rewrite_rules() not working on plugin activation
- Determine plugin name from within plugin_action_links filter
- Having separate plugins and themes folder for multi-site setup
- Is there a plugin to record querystring parameters for a page (for customer tracking)? [closed]
- Where should I add the necessary code to add an extra attribute to the kses allowed tags array?
- Why are some of my thumbnails not being generated?
- Mouse Wheel Anchor Scrolling on WordPress [closed]
- prettyPhoto media loading very slowly in Chrome
- Add keywords meta to index.php page
- Shortcode in widget is printing before the title [duplicate]
- Does anyone know a plugin that turns a ‘post’ into an html newsletter?
- How to check if tables in WordPress still exists after activations
- Working with .po and .mo files translation
- Redirecting a buddyboss profile tab to a different tab if not subscribed to a specific membership
- Unicode characters displaying as ? after import using WP Clone
- Custom wordpress Theme and Plugin repository
- BbPress Register Page in Breadcrumbs
- Problem with removing plugin action
- edit_user_profile and show_user_profile are not firing inside a class
- Every new post/draft has a custom field variable “yst_is_cornerstone” showing
- WordPress Multisite: Programmatically Activate / Deactivate a Plugin of a Specific Blog
- multiple language website navigation menu suggestion
- Woocommerce Change The Price Of A Product Once Woocommerce Has Retreived It From Database
- Tools for styling code snippet in a web page
- composer not working on my plugin when i upload it to my website
- How to get theme’s info from wordpress.org/themes using api.wordpress.org?
- How do I create a custom permalink structure for a page template
- How to remove a class function from a plugin by using remove_action()?
- Visual Composer: Where do I find the source code of a custom element?
- speed up pagination for huge database
- Blurry images when loading the page first time
- Hook for altering the content of all wp mails
- I want to filter my products with attributes [closed]
- Default WordPress gallery or very lightweight alternative to it?
- Rating system for users
- How to add a button to check the emails of my domain?
- Disable plugin visibility at the plugin directory
- Summary and Comments on Main landing Page
- Error activating certain plugins
- WordPress Sitemap for MSSQL
- Method/Plugin/Hack to Start a Post with an Writing Outline?
- Widgets are not displaying in the admin panel
- www redirects to another directory in wordpress
- How to send SMS notification to customer after click on submit?
- Content-Security-Policy implementation with WordPress W3Total Cache plugin installed
- Stripe payment slows down booking page
- How Can I Create A Form In WordPress For Subscribers To Alert Them about new Listing posted?
- Block Google tracking on refuse consent of the user with plugin
- Custom form data not displaying in cart page?
- Failed GET Request From admin.php To Fetch .min.js File From Unminifed Directory
- How to write different events from different functions in my file to a log file in WordPress
- Create a form and have custom menu display based on user answers?
- How to make a plugin api route have permission?
- WordPress eMails not working
- How to wrap image tag into div for post only?
- Problem with conditional woocommerce custom checkout field
- Creating Custom Settings on Pages/Posts For Plugin
- How to add the functionality of WordPress needed to be installed to be mandatory while installing themes
- Content-single.php inside my plugin
- Very Slow loading. Plugins report provided by P3 included
- How To Rewrite WordPress Pages URL Only?
- Change wp_mail SMTP settings for each E-Mail
- WordPress Thumbnail add action if no thumbnail
- How to set the captcha at the bottom of comments textarea
- How do I get WooCommerce to recreate the home page?
- Plugin update, is a deactivation and activation done?
- Update a WordPress website FROM Twitter or Facebook
- How to remove message output for the WP-PostRatings Plugin?
- Pass strings to plugin function [closed]
- How to display a link in the footer section
- How to tweak a plugin without preventing it from updating
- How can I replace the built in WordPress editor?
- Place max_execution_time in plugin [closed]
- Is there a WP-Plugin to convert PNG to GIF? [closed]
- How can I make a quotation engine like this website in WooCommerce?
- Function not being called on form submit, only blank admin-post.php page
- WordPress Convert queries to slashes using function.php
- 404 Error on a WordPress Website, Error disappears for a while and again appears
- ShipStation WooCommerce Integration error
- Failed to update a post when I add a taxonomy to it
- Not Able to Edit Homepage After Updating Elementor
- How to fetch data from the two plugin’s data on the frontend?
- How to add entity in WordPress that have metadata such as name, age