Remove a string from wordpress URL - wordpress

Upon publishing a post through the nice WordPress plugin "Press-this extended" redirects to the published post appending a string on the url which all other posts do not have. The url is as follows: mysite.com/?post_type=post&p=xxxx as opposed to the regular ones which have just: mysite.com/?p=xxxx
What is wanted is simply the omission of the "post_type=post&" string from the urls that have it, which are only the urls generated by this plugin. Using the classic editor does not add this string.
What's the simplest way of achieving this? By a function? By htaccess?
I searched and tried similar questions and solutions but could not resolve it.
Any advice would be appreciated.

Related

wordpress delivers wrong page

Currently running WordPress 4.9.5 using the Divi theme with Permalinks set to use Post name, I can enter a url (page title/name) that does not exist on the site and WordPress will deliver a page that has the “filename” part of the url somewhere in the title/name of the page it delivers but is different than the actual url.
For example, if you go to http://space.nss.org/renew/
Instead of getting a 404, WordPress delivers the page http://space.nss.org/renewable-energy-partnership/
What on Earth is WordPress thinking?
What can I do to identify the exact nature of the problem and fix it?
Note that this behavior is not universal as I can enter bad urls (like space.nss.org/armstrong/) and do get the expected error page.
Thanks in advance, Jim.
NOTE: The url referenced above (space.nss.org/renew/) has now been fixed so its original behavior is no longer exhibited.
With respect to my problem, it turns out that Wordpress is just trying to help by assuming that humans do not know how to type.
When I type "space.nss.org/renew/" and Wordpress doesn't find an exact match, it looks for anything it can find containing the string "renew"
and delivers what it considers to be the best match as a way of avoiding delivering a 404 page to the visitor.
This feature can be turned off but there are consequences in that the 'redirect_canonical' is also responsible for resolving domain name issues (like www.domain.com vs domain.com). For reference, see https://codex.wordpress.org/Function_Reference/redirect_canonical
Following are references on the subject I found once I knew what I was looking for.
[https://wordpress.stackexchange.com/questions/3326/301-redirect-instead-of-404-when-url-is-a-prefix-of-a-post-or-page-name]
2
[https://serverfault.com/questions/776310/how-to-disable-the-automatic-redirection-in-wordpress-htaccess-file]
3
[http://biostall.com/prevent-wordpress-redirecting-to-nearest-matching-url/]
Looking at the network log it appears there is a 301 redirect placed on /renew to go to /renewable-energy-partnership
As a solution you could remove the redirect so that it goes to the 404 page instead.

Wordpress and Woocommerce: remove /product and /product-category from URL structure

Dear StackOverflow friends,
in a site with Wordpress and Woocommerce plugin,
I would like to change the URL of the pages of e-commerce in an SEO friendly structure and in particular I would like:
1) the individual product pages
www.mysite.com/product/productname
to become
www.mysite.com/productname
2) and the product category pages
www.mysite.com/product-category/categoryname
to become
www.mysite.com/categoryname
As regards the case 1 /product,
I have not found a plugin that could help me and I tried
A- to modify WordPress permalinks: inserting a slash followed by a dot /. products , URL takes on the structure that I want but the pages are no longer accessible and bring me an error of 'redirection loop'
B- to modify the .htaccess file, adding the following lines of code
// 301 Redirect Entire Directory
RedirectMatch http://testmywpshop.info/prodotto(.* 301) http://testmywpshop.info/$1
but probably I have not written/inserted that code correctly, because the site becomes inaccessible!
As regards the case 2 about /product-category,
I tried the plugin SEO Ultimate which has the function that suites my needs and I successfully converts the URL structure of product categories, but I'd prefer to get the same result without using it, because my friend wants to use SEO Yoast and there may be conflicts between these two plugins.
In conclusion, I wish URL wouldn't suffer broken links and redirections to be more acceptable to Google (maybe using the 301 redirection because it seems to be the only liked by robots) or even change the WordPress core code that determines the structure of the URL, but I have not been able to find it!
I read this Stack post and this Woocommerce documentation but I'd like to find an alternate way, if possible in your opinion.
I would also be happy to know your opinion about the usefulness of a modified URL structure, removing irrelevant words to the products sold in a e-commerce, to meet Google requirements (I found conflicting information about this subject).
Thanks for your advice and your help!
I would also be happy to know your opinion about the usefulness of a modified URL structure, removing irrelevant words to the products sold in a e-commerce, to meet Google requirements (I found conflicting information about this subject).
If you are looking to do this change to meet SEO Best Practices requirements, please note that this particular URL suggestion happened due to products that belong to multiple categories.
As such, urls that include categories can be detrimental.
www.example.com/product/drinks/milkshake and www.example.com/product/desserts/milkshake point to the same product. However, the problem here is not /product/ but /drinks/ and /milkshake/.
a WooCommerce site with a default product url like www.example.com/product/product-name is technically ok. I prefer to set my urls to www.example.com/shop/product-name as well as www.example.com/shop/category-main/category-sub/ as it is more descriptive. You can do this on WordPress Admin>Settings>Permalinks.
That said, if WooCommerce documentation says it's not a good idea, I usually don't pursue it. :)
Its possible to change the url structure, use a plugin for this.
old situation: domain.com/product/blue-trouser
new situation: domain.com/blue-trouser
or with categories
old: domain.com/product-category/pants/blue-trouser
new: domain.com/pants/blue-trouser
You will have to buy a plugin to get it this way.

Search in wordpress

My problem, when I searched in WP on English language, it's working Good, but when I start to search on Russian or Japanese it's redirect me on page {site.com}/search and shows 404 page.
You might have zero records for that query. Start Searching for those results that could match with your database.
I mean to say search that content which is already in data base, Otherwise you will be redirected to 404 Page.
Do you using custom search script or any hook for search function?
Or you using default WordPress search form?

Wordpress Page - I need to GET variables

I am not a wordpress guy and a client needs me to modify some pages. Someone else has created the entire site in wordpress.
I am having trouble with a query string that contains variables.
wordpresssite.com/pages-using-template/?variable=something
This causes the page to get thrown to the default 404 for the site..
Any suggestions on which file i need to fix this in and how to do it?
Thanks
wordpresssite.com/pages-using-template/?variable=something
That's giving you a 404 error, probably because you're trying to add the query string variable to the home page of the site. There's no "file" that fixes this - WordPress is dynamic. the .htaccess rules handle the URL rewrites ("pretty permalinks")
So I guess you need to give more information on what it is you're trying to do. There's not going to really be a way to "fix" the URL without breaking the rest of the site (it's possible, but I'm betting that whatever it is you're trying to do requires a much simpler solution).
What query string are you trying to add in? For what reason?
For example, I recently did a WordPress site from someone who needed a directory on one page of the site, that had a custom search from in it. I created a function that would $_GET the URL of the page and add the search query to it, and then return the end user to the page with the results there.
You also have to be careful about the $_GET in your functions - you want to be sure they're protected against injection attacks by using $wpdb->escape($_GET['xxx']).

How difficult it is to redirect broken links based on keyword matching?

I currently host a blog on blogger under my own domain. The problem with blogger is that one cannot change the URLs. Page URLs contain "/p/", blog post URLs contain date (which don't even have to correspond to the actual publication date). If at some point I were to move to a self hosted solution and change the URL structure to something more user friendly, how would I redirect the broken links to new URLs, based on extracting the keywords from the old link? Does ASP.NET MVC offer an easy way to implement that?
I ask because I would like to stay with blogger for a little more, but wouldn't like to pay the price in the future.
Check out IIS Url Rewrite: http://www.iis.net/download/urlrewrite

Resources