I have a problem with a Wordpress permalink.
These are my steps to show the problem:
1) in admin > pages: I create new page call "GoodMorning" and I have slug "goodmorning", on frontend, I run ://my_domain/goodmorning will show the content of this page
2) Now, I run ://my_domain/find-me/goodmorning it will auto redirect to ://my_domain/goodmorning
/find-me/ : this is any name and this text does not exist on wordpress slug, category, page, post, ....
Please let me know why. I want it to show a 404 page when I run ://my_domain/find-me/goodmorning.
Thanks All.
Adding this (to functions.php) should stop that redirect.
remove_action('template_redirect', 'redirect_canonical');
If you look at the documentation for redirect_canonical here:
Will also attempt to find the correct link when a user enters a URL that does not exist based on exact WordPress query. Will instead try to parse the URL or query in an attempt to figure the correct page to go to.
I assume that's what you're trying to prevent based on your question.
If you need the other functionality of redirect_canonical you can just cancel the redirect by returning false to this filter, like so:
add_filter('redirect_canonical', '__return_false');
You need to flush your permalinks configuration afterwards:
In the main menu find "Settings > Permalinks".
Scroll down if needed and click "Save Changes".
Rewrite rules and permalinks are flushed.
Related
I recently discovered that a single product in my WooCommerce shows up in search results without its permalink. I cannot find this product anywhere, and therefore I cannot fix the permalink issue.
The link should read as: /nb/butikk/adheseal-2/
But it reads as: /nb/?product_variation=adheseal-2
Which of course just reroutes to the main page. I cannot find this entry in the system so I have noway of fixing the issue. It's a single post problem because every other item works as expected. Not just this particular link. Seeing as clicking the link doesn't work, I cannot find the post ID either.
I have tried to clean up the DB, resetting permalinks etc. but to no awail.
Any ideas?
It was a cache issue that prevented the permalink update.
As mentioned in the Google's "Search Engine Optimization Starter Guide" (pg 11) a good SEO practice is to give the possibility to users to remove manually part of the URL in the address bar.
In my case:
mysite.com/shop/mycategory/myproduct <-- product page with category ok
removing now manually part of the URL above:
mysite.com/shop/mycategory/ <-- error 404
mysite.com/shop/ <-- works
Breadcrumb in the product page look like this:
home / shop / mycategory / myproduct
clicking on mycategory links to:
mysite.com/product-category/mycategory <-- works
The problem is that the two URL differs:
mysite.com/product-category/mycategory
mysite.com/shop/mycategory/
Any clue on how to resolve this?
From looking at the documentation and other similar posts, some permalinks are not recommended to be adjusted for performance reasons. Your
"mysite.com/shop/mycategory/myproduct"
url is actually looking at:
"mysite.com/shop/product-category/mycategory/myproduct"
So it doesn't look like you will be able to shorten it in the way you describe, although you could restore the "product-category" permalink that i assume you have removed? this way the user will be able to shorten the URL without hitting a 404 error.
http://docs.woothemes.com/document/permalinks/
WooCommerce- How to remove product & product-category from urls?
When I open a URL that point to a post which is not published yet, wordpress shows a 404 page. But I want to show a meaningfull message to user that "your post is not published by admin, please contact admin to get it published"
How can I do this?
Edit: Is their any way i can get wordpress to run my single.php template instead of 404 template in my case?
I am not sure, just a hint add script kinda like this to single.php:
if($post['post_status'] == "publish"){
//do something
}else {
// it's not published (i.e. draft or other) so do nothing
}
just do print_r($post) and it will show the full array with keys and values.
good luck !
make url of the unpublished posts something like this.
http://yoursite.com/?p=587&preview=true
And put charlie if else condition in single.php but remember user have to be logged in to see the preview of the post
You can Show unpublished posts, instead of 404 page template by using the_posts filter.
For more information visit this page.
I searched around for an answer. There's a couple that look like this, but most point to a plugin, or feature examples that I can't get working in my case...
So the question:
I created a custom post type for the homepage of my site. I made it the default front page, so now when I enter: localhost/vhh I automatically get forwarded to this page: localhost/vhh/homepage/homepage
The first "homepage" refers to the custom post type. The second is the name of the "post".
Now I want to remove both, or at a minimum 1 "homepage", so I get:
localhost/vhh or localhost/vhh/homepage
Can this be done with a WP rewrite rule? And how?
I have the following page which contains a single post and a number of comments.
http://mysite.com/tips
When a user posts a comment, I add meta-data to it so I can filter comments by using these URLs:
http://mysite.com/tips?id=cat&filter_id=1
http://mysite.com/tips?id=dog&filter_id=2
I want to use the following url's instead:
http://mysite.com/tips/cat
http://mysite.com/tips/dog
I worked through this tutorial, which seemed to be what I needed, but when I type in my url, I get a page not found error. http://thereforei.am/2011/10/28/advanced-taxonomy-queries-with-pretty-urls/
Is this possible?
Go to the admin's dashboard using mysite/wp-admin. Then click on the pages option to view all the pages. Click on the desired page name to edit that page. Just below the name of the page you can see the permalink. Edit this to change your page's URL.