Changing Woocommerce My-Account Slug/Permalink - wordpress

Woocommerce wordpress "My-Account" slug.
I'm attempting to change the .com/my-account/ slug to .com/account/
I can successfully do this through page editor and changing the slug, But once i have done that i lose the display of the dashboard.
Refer to photo's below.
My-Account Slug
Account Slug
Thank you.

There are 2 ways to do the same,
You can change the slug from WP-Admin->Pages->My Account page.
By defining custom rewrite rule in the .htaccess file.
function custom_rewrite_tag() {
add_rewrite_tag('%myaccount%', 'my-account');
} add_action('init', 'custom_rewrite_tag', 10, 0);
Source: Changing Woocommerce My-Account Slug/Permalink

Related

Wordpress Custom Woocommerce category page

I have pages for every category in woocommerce. These are listed as follows:
http://example.com/parent-category/category-a
http://example.com/parent-category/category-b
http://example.com/parent-category/category-c
I want to customise the last link to be a custom-built page but still retain the link and not just doing redirects.
I currently use WooCommerce Permalink Settings plugin
Create file "some-single.php" and after this create "some-yourCategoryName". Now open single.php and and replace this get_template_part('content','single'); by following code
with this:
if(is_category('yourCategoryName')){
get_template_part('content','yourCategoryName');
}else{
get_template_part('content','single.php');
}
Will be fine.

Show custom post archive when custom post not specified

I have a custom post type called produce set up in WordPress and a custom taxonomy called produce_category.
The URL format for posts in this custom post type is in this format http://mywebsite/produce/%produce_category%/%postname%/. Of course %produce_category% and %postname% get substituted accordingly, a working example url would be http://mywebsite/produce/fruits-and-vegetables/avocado.
What I would like to do is show the produce_category custom taxonomy archive if a user visits http://mywebsite/produce/%produce_category%, without specifying post name at the end, e.g http://mywebsite/produce/fruits-and-vegetables to show all produce in fruits-and-vegetables produce_category.
Besides that when a user visits http://mywebsite/produce/ I would like to show all the produce archive. EDIT: I have this working now.
I know how to create the archive pages totally fine and have no problem with that. I am stuck at creating permalinks. When I visit http://mywebsite/produce/%produce_category% I get a 404 error.
I'm looking for advise on the best way to implement this. Currently I am using Custom Post Type Permalinks and CPTUI.
The CPTUI custom taxonomy settings interface does not allow me to have a blank in the custom rewrite slug. It defaults to the custom taxonomy slug, produce_category, when I don't fill in anything.
This gives the front-side produce_category taxonomy archive url as http://mywebsite/produce/produce_category/%produce_category%/ e.g. http://mywebsite/produce/produce_category/fish-and-seafood/ when what I want for the archive is http://mywebsite/produce/fish-and-seafood/.
Please help with suggestion on the best way I can achieve the custom taxonomy url.
Thank you all.
Try this code. It will help you to achieve your url structure... Make sure you update permalinks after saving it to functions.php
function custom_produce_category_link( $link, $term, $taxonomy )
{
if ( $taxonomy !== 'produce_category' )
return $link;
return str_replace( 'produce_category/', '', $link );
}
add_filter( 'term_link', 'custom_produce_category_link', 10, 3 );

I've enabled categories for pages, how do I show the category of the page in the url?

I have registered categories for my wordpress pages with the following code:
function add_cat_2_page() {
register_taxonomy_for_object_type('category', 'page');
}
// Add to the admin_init hook of your theme functions.php file
add_action( 'init', 'add_cat_2_page' );
In Permalinks I have set up the custom structure like so:
/%category%/%postname%/
Unfortunately, it displays the page with the defined structure only for posts, not for my pages!
I need the contrary: I want only the pages to have that structure, not the posts!
Try Yoast
Under Search appearance go to taxonomy and check Category URLs then you can
Remove or include the categories prefix.
This will solve the issue if I am correct on what you are trying to achieve.

How do I enable author pages for the role of 'customer'?

I have a website where a customer can enable a front end 'profile' page. These customers have the role of 'customer' as defined by wooCommerce. However, this user role does not provide enough privilege to enable an author page for that user. How do I add the capability of an author archive?
In an ideal world I'd like to continue to use author.php as the template instead of creating some sort of work around author template.
Adding the following code to function.php file will add wp-admin toolbar for all users including customers.
This plugin will help you to add code from dashboard: https://wordpress.org/plugins/code-snippets/
/* Allow customers to access wp-admin */
add_filter( 'woocommerce_prevent_admin_access', '__return_false' );
add_filter( 'woocommerce_disable_admin_bar', '__return_false' );
Alrighty! Figured it out. Thanks, everyone for the answers, however, this is for a front-end author page, not backend access.
// remove wooCommerce redirect from authors.php template
remove_action('template_redirect', 'wc_disable_author_archives_for_customers', 10 );
Turns out WooCommerce disables author archives for customers. In my case, a customer is also a member and therefore I need to author.php template accessible.

Products disappearing when adding any category on WooCommerce

Has anyone experienced this before? This is my first time working with WooCommerce.
If I don't add products to a category they will show up in the main shop page as well as have a single product page, as soon as I add a category they will not show up on the main shop page, the category page, or the single product page.
I have not manipulated the wp_query in any way on the page.
I am integrating it into my custom theme which is really barebones, the only thing I have changed is the following in my functions.php file:
remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10);
remove_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10);
add_action('woocommerce_before_main_content', 'urbantac_wrapper_start', 10);
add_action('woocommerce_after_main_content', 'urbantac_wrapper_end', 10);
function urbantac_wrapper_start() { echo '<div id="products-content" class="products wrap clearfix aligncenter content-container">'; }
function urbantac_wrapper_end() { echo '</div>'; }
I was using another WooCommerce plugin:
http://www.woothemes.com/products/catalog-visibility-options/ to turn off the "store" functionality of WooCommerce and use it as a "catalog"
This adds two settings on the product category pages, and sets defaults to NOT show anyone the content (no idea why this is). The settings are Role Visibility Rules and Location Visibility Rules. It does not mention this anywhere in the documentation for the plugin!
So if you are using this plugin you can no longer create categories directly from a product page, you must first create the category, set the visibility rules, and then create the product.

Resources