wordpress - Rewrite post permalink - wordpress

I've a custom post type that it can view on mywebsite.com/custom_post_type/ (with archive.php), but I don't understand how change permalink of "post" (default type - articles).
This is what I need:
I want to read all "post" with this url: mywebsite.com/news/. "News" would the slug for "post" type.
I think it's necessary to rewrite the permalink, but I didn't found anything on google.
Can you help me?
Thanks

I'm not 100% sure I understand your questions but I think you are trying to do is view all 'Posts' under mywebsite.com/news/ - In that case simply create a page called News (with the slug/permalink as news) and then in Settings > Reading - set the Front page to 'A static page', with the front page selecting your 'Home' page and the Posts page set as 'News' (the page you just made).
If you are talking about viewing all posts of a custom post type under news, either name the post type slug (under your rewrite array setting when you register the CPT) as News.

Related

WordPress custom field permalink

We're creating a WordPress website that uses custom posts and custom fields. We're using the "Custom Post Type Permalinks" plugin for our links and "Custom Post Type UI" for our posts.
Our current links are like:
http://example.com/<custom post type>/<custom taxonomy>/<custom post slug>
Example:
http://example.com/my-custom-post/my-custom-taxonomy/my-post-slug
What we're trying to achieve is:
http://example.com/<custom taxonomy>/<custom post slug>
Example:
http://example.com/my-custom-taxonomy/my-post-slug
Although it is achievable by setting the custom post values to the following:
Rewrite: True
Custom Rewrite Slug: %my-custom-taxonomy%
With Front: False
But when I do that the link goes to a 404 page. It seems that WordPress cannot find the post or recognize the custom post.
We already did the flush_rewrite_rules() but the problem stays the same.
How can I make the link open the requested post?

WP Rewrite api gets confused with post type slug and detail blog page slug

I have following structure in my website:
I have a post type called Destination and slug of post type is "destination".
So I can access destinations archive page using following url: domain.com/destination.
Now the default blog posts are related to a single destination. For example i have a blog post called places to visit in london. So I have to relate this post to london destination. Which I am storing in my post meta.
Which is easy and I have done it.
But the problem is I need permalink structure in following way.
Destination archive page: domain.com/destination
Single blog page: domain.com/destination/london/blog/places-to-visit-in-london.
I have used WP rewrite API for this. I have followed this artical from tuts plus.
You can find my code on pastbin:
http://pastebin.com/g74zZYUk
I have simply created two tags (%destination_cpt% and %destination_name% )
And those tags works fine and post links works like it should.
But when I open the blog post in frontend it gives me 404 error:
domain.com/destination/london/blog/places-to-visit-in-london
Due to destination slug exists as a post type.
If we use destinationsxyz as a first slug for default blog post, then default blog post and destination archive page archive page works fine.
But then if we write any first or second or third level wrong url like domain.com/abc or domain.com/abc/xyz or domain.com/abc/pqr/xyz then it leads to default blog page (which we set in settings->reading) of site but actually it should lead to 404 page and now only and only if you use wrong url having 4 levels like domain.com/des/abc/xyz/pqr/efg, it will lead to 404 page.
This happens in default WorrdPress installation with default WP theme (twentysixteen) with no plugin installed or no other extra piece of code theme.
Any help is appreciated.
Thanks in advance.

WordPress custom post templates

I am new in WordPress world. I created custom post successfully and I displayed it on page template page. Now I want to use taxonomy-{category}.php and single-{post}.php for displaying custom post but I am confused in taxonomy page and single page. How can I achieve this?
In taxonomy-{category}.php here category means our custom category name or others?
In single-{post}.php here post means custom post name or others?
See the Template_Hierarchy on the Wordpress Codex
taxonomy-{taxonomy}.php - If the taxonomy were sometax, WordPress
would look for taxonomy-sometax.php
single-{post_type}.php - If the post type were product, WordPress would look for single-product.php.
Example:
For post_type
When on an online store custom post type in the backend, the URL would be wp-admin/edit.php?post_type=store.
So the post_type in this case is store, which means I will name my file single-store.php
For taxonomy
When on the Categories page for the online store in the backend, the URL would be edit-tags.php?taxonomy=store_categories&post_type=store
So the taxonomy file would be taxonomy-store_categories.php
In taxonomy-{category}.php here category means our custom category name or others?
taxonomy-{category}.php here category means your custom category(taxonomy)
In single-{post}.php here post means custom post name or others?
single-{post}.php here post means custom post type name

WordPress Custom Post Type Issue

my situation is I registered a custom post type named 'products' and I included 'has_archive' => true in the parameter to enable an archive template for this custom post type, I also created a archive-products.php as the template for displaying post per taxonomy of 'products', but what I noticed is when I enabled 'has_archive' => true what happens is archive-products.php acts as the index page template of the 'products' custom post type instead of the 'page-products.php' file that I created as the index page template for listing all the post of 'products' custom post type.
then when I click a link to the product-category this archive-products.php uses the default archive.php as it's archive page template. it really acts weird and now I don't know what to do next.
what I want to happen is prevent this from happening and let page-products.php act as the default index page template for listing the posts (as it should be) and for archive-products.php to be used by page-products.php as it should be doing.
thanks I hope someone can help me into this issue.
by the way I'm using WordPress 3.5.1
I faced the same problem in the last days, and take a couple of hours to search for a solution, in my case the solution was to add this following functions to you functions.php file: flush_rewrite_rules(false);
I hope it can help you :)
you can check this plugin for your custom post display
wordpress.org/plugins/wp-custom-post-field
on here create your custom post and use shortcode for display post.

Same string for custom page type and slug

I have a custom post type team and a page titled "Team" whose slug is also team.
Team page is assigned to page-team.php (template name "Team"). team custom post type uses single-team.php template file. When my browser points to /team it uses the index.php template instead of the page I wanted (the team page file).
How can I correct this?
From the Wordpress Codex: Post Types section URLs:
The new post type will also get its own special section of the site layout. In the above example, posts of this new "product" type can be displayed at http://example.com/product/%product_name% (where %product_name% is the URL-ized name of your product, i.e. http://example.com/product/foobrozinator.) You can see this link appear in the edit pages for your new type, just like other posts.
This means:
Your custom type team pages are all reachable under http://example.com/team/%slug%.
Since your slug is team the url is http://example.com/team/team.
Makes sense. The Codex page about custom post type is worth a good and thorough read.
Edit: If you aren't happy with /team/team, try the Custom post type permalink plugin.

Resources