I have a worpdress website that is set with a permalink structure to:
mywebsite.com/%author%/%postname%/
Now, I have a post that is written by multiple authors - what we wanted to achieve is that we should suppose to be able to access the post by going to any of the author in the url such as:
mywebsite.com/author1/mypost
mywebsite.com/author2/mypost
This actually works, however for some reason when I go to:
mywebsite.com/author2/mypost
this redirects to this:
mywebsite.com/author1/mypost
I think this is due to the base permalink wordpress enforces?
How do I make it so that when I go to the link of a certain author, it will retain the author in the permalink?
eg.
Going to mywebsite.com/author2/mypost should direct to mywebsite.com/author2/mypost
Related
I have looked all over the place and can't figure out how to get this to work.
I want my urls for blog posts to look like this: "www.website.com/my-page/category-name/blog-post-title"
The issue I am having is that I have a page called "my-page".
So I have a page "www.website.com/my-page/" which is just a standard wordpress page, but I want the url for the blog post to look like it is under that page.
Here is what I have for the permalink so far:
/my-page/%category%/%postname%/
But this doesn't work and gets a 404 error when opening a blog post.
At this point I don't believe it can be fixed through the wordpress gui, so if anyone has any recommendations, it would be appreciated.
Thanks!
Edit: I wanted to add that the permalink works fine if I remove "/my-page" or if I simply modify it so it does not match the page.
First of all you should not use the category in front of your permalinks as it leads to bad performance (and some posts may have multiple categories): http://ottopress.com/2010/category-in-permalinks-considered-harmful/
The second thing is - it should work. I tried with a fresh installation on WordPress and I get the correct results.
Did you flush rewrite rules / save the new permalink structure?
Did you publish a post?
Is your server correctly configured to use permalinks?
Third possibility - if your permalink structure does not work for some reason you can define a custom permalink structure:
https://codex.wordpress.org/Rewrite_API
I had a previous coder move my site from a custom cms to a custom wordpress theme.
Posts are shown correctly when there is no post-id in the permalink. However, I would like to include the postid on the site posts. My permalinks now look like www.website.com/post-title/ although I would like them to be www.website.com/123/post-title/. I believe all my issues are coming down to one function.
http://pastie.org/10498435
The code on that page does various things based on vars found in the url. I am not 100% sure if this is the only problem, but it is the only one I can find. I have a custom post type created on my site that seems to work fine. The permalinks seem to fully work. When visiting a post page with the postid in the url (changing it via the permalink settings) I get a 404 page. I also get a 404 page when I try and view the author page. I have no clue where to even begin to figure out what the problem is with the author page.
Site: http://www.frontdesktip.com/blog/
I did a great amount of research and came across some solutions like this:
https://wordpress.stackexchange.com/questions/106042/force-wordpress-to-show-pages-instead-of-category
But still it isn't exactly what I'm looking for. First of all let me explain the problem.
I made a page /blog/ and a category 'blog' both make use of the permalink /blog/, disabled the /category/ permalink so the SEO will be correct.
The solutions I came across didn't match the following requirements:
Not using 301 redirects
Disable the /category/ use within Wordpress.
Also make it possible to only replace category when a page id uses the same slug.
I simply like to tell Wordpress to display the page instead of the category.
Why don't you just edit the category template?
Because the page I created uses Visual Composer (Post Masonry Grid) so I can't simple move the design.
Why don't you just use redirects?
I would like to but the permalink of the blog is the same as the page (SEO purpose.)
I know it's a few years later with no solution, but I had the exact same problem you described on one site that was working in other sites. So I did some research on what was different and to help others should they run into the same issue.
Background
example.com is the domain
I have a WP page called "foobar" with content
I have a WP post category called "foobar"
I have a WP post entitled "fun things to do with foobars", and the category is set to "foobar"
Expectations
When I go to example.com/foobar, I want to see the page about foobars, not a WP category page that shows all blog posts with that category.
When I go to the blog post about fun things, the URL is example.com/foobar/fun-things-to-do-with-foobars/
Setup
Here's my setup (it does not require any additional plugins or code edits)
A couple of installed plugins are WP Rocket and Yoast on which I'll focus in this thread.
WP Dashboard->Settings->Permalinks
Select "Custom Structure" and enter /%category%/%postname%/ in the field
On the same page, change "Category base" to a single dot. "." (no quotes, just a single dot/period/full stop
I have Yoast installed, which I had set up to override the permalink settings, but I believe this messed up my task at hand.
WP Dashboard->SEO->Advanced->Permalinks(tab)
"Change URLs->Strip the category base..." = Keep
Then you need to clear the cache. I use WP Rocket for caching, so I flushed the cache and everything now works the way it should.
Edit: make sure you save your changes after steps 3 and 5
I know this topic is old but question is still important.
I will use blog example.
This method is code free, WP native solution. One caveat is that you cannot translate "blog" slug, so this method is only for one language if you don't need to have different words/slugs for other languages.
Create page with slug "blog". Or whatever you like. It must match word you put in next step as base: blog = blog it this example.
Set permalink structure in settings to: /blog/%category/%postname%/ (/ trailing slash on the end is your preference)
Use SEO plugin like Yoast or Seopress Pro (or any other
method) to remove /category from URL.
Go to Settings -> Reading -> "Your homepage displays" section -> "A static page (select below)"
Set your static page for Homepage
Here is the magic: set Posts page to your "Blog" page.
Flush permalinks by visiting and saving settings on Permalink page (without any change).
Then you will get proper URL: /blog/yourcategory/single-post-title/
Breadcrumbs will work, all categories will be hierarchical, and /blog will work as page instead of category.
Most importantly, when you go to your category page you will get /blog/yourcategory URL and it will work as archive page. When you visit single post, then also you get URL /blog/yourcategory/single-post-title/
Breadcrumbs from Yoast should work. I use Seopress Pro and breadcrumbs works like a charm (you have to go to breadcrumbs setting page and select categories for posts and posts for categories and tags if you need them).
If you do it without including /blog in your permalink setting it will still work, you will get page instead of category with proper url for categories, but single post will be /yourcategory/single-post-title.
I am changing my site from Drupal to WordPress. There are many articles written.
Every article has url like given below.
http://example.com/blog/simple-post
How can I achieve this in WordPress.
For now I am using.
http://example.com/simple-post/
you can set it up in settings->permalink and set the option to custom type, then you add this type of permalink : /%category%/%postname%/ instead of just /%postname%/
Then you just assign any category to your posts, like blog, shop, portfolio, team etc whatever you want without having to worry how to set that permalink for lets say two, three types of urls
If you want to keep the exact same URL structure, look at "Permalinks" under the "Settings" option in the admin section.
You can set a custom permalink structure like:
/blog/%postname%/
Edit permalinks in wordpress settings page
Custom Structure http://example.com /blog/%postname%/
If you need category in url
Custom Structure http://example.com /blog/%category%/%postname%/
I have a website that is a custom PHP site hosted at http://mysite.com. Then I have a Wordpress instance running on sub-domain at http://blog.mysite.com, where some post can be at URL http://blog.mysite.com/this-is-my-test-post-entry
In landing page of mysite.com I connect to Wordpress DB and fetch out last 5 entries from wp_posts table and show them on my home page. The problem is I don't know how to get the right links to those posts? Wordpress generates permalinks() but I don't know how to get them?
I thought Wordpress takes post title string and replaces spaces with "-" and uses that string for post URL. But doesn't work for all posts...
Any suggestions?
This may not be exactly what you are looking for, but it will work...
When you fetch your last 5 posts, get the id (make sure you're filtering on your post_type field to avoid grabbing things like revisions, attachments, etc).
You can simply build your URL like http://blog.mysite.com/?p=ID (where ID is the ID from the database). WordPress will automatically redirect the user to the proper page with the custom permalink that you defined in your settings.
Let me know if you need a hand with the PHP.