I'm building a custom theme, with a custom post type. If I want to use the WordPress pager in the back end - to navigate between pages of posts - the URL it directs me to is wrong and I don't know where to even begin.
So the dev url is set up as
http://socor.dev
when I want to go to page 2 of the pages the URL should be:
http://socor.dev/wp-admin/edit.php?post_type=page&paged=2
however the domain part of the URL is being stripped out and I'm left with:
/wp-admin/edit.php?post_type=page&paged=2
I noticed when looking through the front end code that this has been set:
<link id="wp-admin-canonical" rel="canonical"
href="http:///wp-admin/edit.php?post_type=page&paged=2">`
I am running the latest version of WordPress 4.5.1
In case anyone comes across this, I've managed to work out what was going wrong.
I had managed to overwrite my domain name somewhere. I used:
var_dump($_SERVER['HTTP_HOST']);
in my functions file to see what I had it set as.
It was weird because the admin area would load up fine in the first instance but would go through 404's and other errors when navigating through additional post pages.
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 have a strange problem with my site. It is a wordpress site working for a while now, and our company started some Adwords campaigns to boost views. Google Adwords adds a gclid parameter to the URL when clicked, and the site is loading another template (the default post template) instead of the template for the homepage.
I'd like to know, where to start searching for the faulthy parts? Any ideas?
Thanks!
PS: Not just the gclid parameter does this, but all other fake parameters too. Strange thing is that only the homepage does this, the other pages with structured URL-s are not doing so. The site uses Visual Composer plugin, if it is important. We tried to solve the problem by .htaccess file, but the redirect causes an error in Analytics tracking of Adwords visitors, so it is not a solution.
Finally, we found a solution!
The theme lacked the front-page.php template for the homepage (read more about wordpress template structure!), so I created it with the correct template HTML code according to the correct layout variable values, and it loads just fine. The URL parameters are not affecting the permalink structure anymore, because now we have a template for the homepage too.
This is better than doing hours of research for redirect- or permalink method workarounds...
if everything fails please use template_redirect hook to load any template you want... template_redirect hook
Also you have to send a 200 OK header there if you simply load file and exit.
I built a Wordpress site locally using MAMP, where I set up a page with a custom page template which displays a custom post type in a certain format. When I moved everything across to the live server, the custom page template doesn't work as I expected, and just shows what I assume is a default posts archive page (see example: http://www.hiblio.tv/rewind). What's weird is that if I set up a new page with a different permalink, it works fine (example: http://www.hiblio.tv/archive).
I've tried deleting both pages, removing them from the trash and starting again, but whatever I do, I can't get the page to display properly with the 'Rewind' url, which is where I need it to go. Any ideas?
I have following weird problem in Wordpress using permalinks.
When I use the default setting for permalinks, everything works just fine.
But I want to use the post name as permalink.
When using the post name, one link opens the home page instead of the actual page.
Manually changing the permalink in the page settings leads to a 404 Error.
I dont think this is the problem but the links form the pages have some similarites:
Home page: www.website.com/name1/
Site with problem: www.website.com/name1/index.php/name1/
What makes it even worse: when i set the parent of the page to home, everything works.
Changing the permalink manually to another string worked in the end.
Might be a bug from wordpress with same names.
I am working on making urls like example.com/profile/username to work where example.com runs Wordpress(latest release). The install is on root. I wrote a plugin hook to catch template_redirect and I examine the URL to see if it is a profile request and then I show the profile.
But, when a URL that does not exist is typed, Wordpress does an auto search for related posts before triggering a 404 or template redirect.
For example, example.com/profile/foobar goes to another page which has foobar in its title like example.com/2009/10/1/foobar
How do I stop this from happening?
I haven't upgraded my wordpress blog in probably 2 years (posts or software), but my first thought was a .htaccess file. I looked at the main one and found:
But that doesn't explain search results right off. So I found this file
/wp-includes/rewrite.php
which has a few dealings with permalinks and search results. The main one I spotted was:
// Search
$search_structure = $this->get_search_permastruct();
$search_rewrite = $this->generate_rewrite_rules($search_structure, EP_SEARCH);
$search_rewrite = apply_filters('search_rewrite_rules', $search_rewrite);
Basically, if all searches are turned into permalinks and all permalinks are rewritten to a script that creates a generic page, you get the /foobar page...
I'll keep you posted on what I find.