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.
Related
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.
I’d like to edit the "checkout" default WooCommerce form (fields like : billing address, first name, second name...etc.), but woocommerce template file form-checkout.php is not present in Avada Theme; other template files in woocommerce/checkout folder does not contain code for checkout form generating.
Where can I find template or define new custom template for checkout form in Avada?
I think the exact file you may need to edit is form-billing.php which is under woocommerce folder,the relative path not the form-checkout.php :
..\wp-content\plugins\woocommerce\templates\checkout\form-billing.php
you could edit this file in your child-theme by following these steps:
https://www.dreamhost.com/wordpress/how-to-customize-woocommerce-child-theme/
I'm currently working on a custom post type and want to be able to edit the archive page from Wordpress with a page template. So I created the CPT called 'cars' and created a page template with template name: 'Cars overview'. Next i create a page inside WordPress and choose the template page 'Cars overview' and gave it the URL: mywebsite.com/cars/
Now the problem is that the slug 'mywebsite.com/cars/' is already in use by the custom post type itself causing the page to load the custom post type loop instead of the page template loop. So I can't edit the title, content etc inside WordPress. I could change the url of the page, but i want to be able to control the overview page in WordPress.
Long story short: How can I create a page template that is using the same URL as the custom post type archive page?
Thanks in advance!
One simple solution, simply disable the archive where you create your custom post type:
register_post_type("cars", array("has_archive" => false));
Another approach rather then disabling the archiving and adding another page to show the cars. Changing the archive template used by your theme might be a better option.
First step is to find the template currently in use by your theme, copy it to your plugin file and you can change the template file to whatever you like. You can find more information about it here.
The only thing you need to do is point WordPress to the right direction:
add_filter("archive_template", "archive_template");
function archive_template($archive_template) {
global $post;
if ($post->post_type == "cars")
{
$archive_template = "path/to/your/template.php";
}
return $archive_template;
}
Disabling the archive and creating one manually seems a bit strange to me. And I always replace the archive page and sometimes single page from our theme (usually the7).
Is it possible to rewrite only one category ?
I have a category "Photos" and just for this category.
I just want to rewrite it from /category/photos to /photos
You can do it with WP Rewrite API.
Add this to functions.php
add_action('init', 'register_rewrites');
function register_rewrites() {
add_rewrite_rule('^photos$', 'index.php?category_name=photos','top');
}
Remember to reload your rewrite settings: go to Settings -> Permalinks and click on Save button - no changes needed.
The Yoast SEO plugin has this function build in, I recommend this plugin in general.
no-category-base-wpml only does this
If you don't want to install a plugin for this. Around the web there are many tutorials which do this:
http://thisismyurl.com/6704/remove-category-url-wordpress/
http://www.webdevtuts.net/php/how-to-remove-category-from-wordpress-url-structure/
http://www.wprecipes.com/how-to-remove-category-from-your-wordpress-url
Too enable this for just one category I would advise the following:
create a page called photos.
create a theme template page for this photo page
In is set up a new query_posts* getting the category 'photos'
Include the category.php file.
assign that template to the photo page.
Not tested but should work. Because the page has the correct URL and should include the category. Questions, aks.
*query_posts is bad for performance if you want to do it totally correct use the pre_get_posts filter. It's requires more knowledge.
I'm using WordPress and I've made a number of posts. What file do I need to edit, so the same HTML shows on the bottom of all the posts?
there are so many file wordpress theme structure if you want to edit:
(i think you Edit single.php)
page.php : use for simple page
index.php : use for post page
single.php : use for single post if you want to change ur post setting
similerly footer.php, header.php
The default name of the template file used to display pages in Wordpress is named page.php. It is located in your current theme.