get variable from a wordpress permalink - wordpress

i have this wp page that display the preview of the products and once click it will send to the other page with full details of the product. Actually this worked on not pretty permalink but hopefully trying to make it search engine friendly
preview page:
http://localhost/phone/brand
full page:
http://localhost/phone/specs
sample link:
NOKIA-3210
Then specs/full page will get the "nokia-3210" string from the url to use in the wp query. but this redirect me to 404 page.
How can I go about fixing this? I've read that this can be fixed using .htaccess also rewrite_api, I'm lil confuse what to use. Any help to point me to the right direction?

I've never done this but I would guess some changes in the htaccess file would be required to force all visits onto the specs page itself and not treat nokia-3210 as a post/page.

Related

Wordpress - /page/2 not working but /?paged=2 is

I have a WordPress site where my front page is showing the latest posts.
If I have my permalinks set as plain showing...
https://example.com/paged?=2
The page loads. However, If I change the permalinks to Post name, giving me...
https://example.com/page/2/
That results in a 404.
.htaccess seems to be set up correctly. The first page has posts and the links are being generated in the pagination controls. Using Post name as the permalink setting my posts are properly linked...
https://example.com/my-wordpress-post
But https://example.com/page/2/ does not work.
Any ideas? I really need to set the permalinks to Post name. Could it be a server issue?
First thing I would recommend is to confirm your .htaccess file is set up correctly to process permalinks. If you create a new page, can you access that page with his human-friendly permalink, for example? If not, you may need to fix your .htaccess file to handle those rewrites properly.
Otherwise, can you provide more context for this issue? Is it safe to assume you have your homepage set up with a list of paginated posts?
I figured this out. Instead of selecting Post Name, I select the Custom Structure radio button instead and manually added /%postname%/ and then clicked saved.
Then it worked. :)

Permalink Linking Issues (Wordpress)

My current blog is www.bostonsbettah.com and my current permalink set-up is http://www.bostonsbettah.com/%category%/%postname%/
Now, in a perfect world, the a post should appear as something like www.bostonsbettah.com/bostonbruins/boston-bruins-1st-line-playing-like-a-1st-line/ and that should take you to the post. When I click on the page title at the top such as "Bruins Blog", it should take me to www.bostonsbettah.com/bostonbruins/ that has an archive of all posts categorized as "Bruins". Currently, however, every page besides the home page is a 404 error.
Now I know I can fix something in the .htaccess file and I know how to access it, but I don't want to mess with it as I don't know how to code. Is there a fix someone can provide that will allow me to fix my website? Thank you in advance.
Never,ever,ever put your blog URL inside custom permalink structure!. You must use one of the structure tags, or a combination of tags only.
Read the documentation first.

Images within a post display fine but clicking on images return 404 not found error

To start with, I am not an expert of any kind. Codes drive me insane. I run a site called: http://nascentarray.com.
I moved the site from one host to another and after the migration, I found that many images were broken. So, I changed the permalink structure:
From: nascentarray.com/post-name/
To: nascentarray.com/year/month/date/post-name/
Everything looked fine until I started getting 404 errors on images interested into the posts directly.
To me more specific, I use two methods to insert images:
I use the Jetpack module of WP to create a gallery in mosaic layout that gives a carousel of images when someone clicks on the gallery.
For some posts, using Jetpack gallery module makes no sense and so, I simple insert individual images between texts using the simple media uploader.
Problem: The problem is with the posts where I do not use the Jetpack gallery module. When I click on a post, the post opens fine and shows all images in it. However, the moment I start clicking on individual images, they start giving 404 error.
Example: http://nascentarray.com/2013/02/08/tallest-buildings-of-2013/
Clicking on any image in the post will return a 404 error.
How to solve this problem? Anyone, please help me. This is so disturbing and I don't have enough technical expertise to deal with this on my own and so I can came here with a hope to find some help from experts.
The posts where you don't use jetpack image gallery module doesn't embed a gallery. Instead, you embed images in your posts individually. When you embed, there's option with image link whether you want to link image with post, attachment page, custom link or source file.
Your images are not linked to source file - instead those are linked to POST ATTACHMENT link.
Once you changed the permalinks structure of your post, the links associated with your image files were not updated and those remained as per previous permalink structure those don't exist now and thus it gives 404 error.
It's solution can be to revert your permalinks structure to previous one (short and immediate solution) and other solution can be writing a short script and update all links of images in batch with their source file or anything else.
Another solution is to use Yoast SEO plugin to generate redirect URL's for old backlinks.
See the guide in this blog post regarding this solution.
I hope this helps and you understand the issue now.
Your permalink structure is incorrect. You need to change it back to nascentarray.com/year/month/date/post-name/
If it's already that way, then you need to double check your folders in uploads. Because if you look at your one page here http://nascentarray.com/2013/06/17/stock-wallet-the-only-wallet-you-will-ever-need/
That image is linked with ../year/month/date/post_name/image_name/
i.e. http://i0.wp.com/nascentarray.com/wp-content/uploads/2013/06/stock_wallet_2.jpg?resize=389%2C176
Obviously your plugin for viewing galleries adds the extra stuff in the URL's.
Where as the link you gave above has just ../post_name/image_name/ Which isn't working with your plugin or linking of the image file.

Wordpress url not including category on main page

I am new to wordpress so trying to figure out something which I cannot and asking you guys. Please help if you know.
I have issues with URL formation in Wordpress. I want to show articles' category name in URL, so I am using Permlinks -> custom structure which is like /%category%/%postname%.htm I then pasted code given by WP in .htaccess file. So now articles use http://mysite/category1/article1.htm URL.
But then on index.php any links inside article shows URL ashttp://mysite/article2.htm and hence 404. I am using >Article2 inside a post. If I open http://mysite/category1/article1.htm then above link will show as http://mysite/category2/article2.htm which is the correct URL.
Can someone plese help me figure out correct way? Using above configuration, it works fine for all links when open individual posts but only main index.php does not include category name. Just to note, URLs in Recent Posts also show correct URL.
If the links are hardcoded inside the article itself, there's nothing inside WordPress PHP or settings to change. You just need to edit the post content and update the HTML link URLs using the new permalink structure, within Posts and/or Pages tab.
You can also try a plugin like Redirection which will redirect old post permalinks to the new (correct) permalink format.
http://wordpress.org/plugins/redirection/

How to redirect wordpress post links that are using post_id to new url struture of postname

I have a slight problem... we made a change to our url structure the other day and have broken links all over.
What I did was change links from:
http://blog.mydomain.com/articles/123
To:
http://blog.mydomain.com/articles/this-is-a-smaple
Is there anyway to direct any links linking to the pages ID number to the postname????
The old url structure is still being published throughout our RSS feed on facebook. So I am trying to catch those people that are or maybe clicking on our links on our facebook posts and redirect them to that posts postname url? Does that make sense?
Thanks and help would do
Matthew,
You can use the Advanced Permalinks plugin. It'll redirect old permalink structures to the correct posts. Checkout the description on the plugin page.
In your new URL handling code, check to see if everything after the last slash is decimal numbers, if so, use the old URL handling code.

Resources