I'm using wordpress v2.5.1, and Google has some pages in its search results that take people to the 404 page. Now, on the 404 page, I would like search to be performed (automatically) based upon the words in the title link that they used on Google to enter my site. For example, say someone found my site on Google while searching for the keyterm, "X" . As it is now, when they click on that Google link to my site, they are taken to the 404 page because the link to "X" wasn't found. However, I know that there are other posted related to "X" present and active -- most likely in the site archive. How would I put up a list of related posts, relating to "X" on the 404 page to help people find what they were looking for?
Can you believe it? I made this post several minute ago, and now it's appear in the Google search results. http://www.google.com/search?q=Similar+Posts+on+404+page&hl=en&pwst=1&start=10&sa=N Wow. Google loves DP.
Google surely loves Dp! And it should cause Dp is a good forum. And for your issue, you need to set up a 301 redirect Just google 301 redirect set up on wordpress girly! If you still cant find anything, just let us know here again and we will surely try to help.
Well, I suppose that I'm wondering how to pass along the search term from Google into my blog in order to display 5 or so links to posts about the search term. I don't want to substitute the 404 header for a 301 header because I do want older information to die and go away ... however, I don't want to lose human readers because of a boring and information-less 404.
Hmmm very reasonable 'reason' to say the least. Which exact page is showing that? You know my site was showing that too, but thankfully they were all author pages and I simply added no follow to them. However since its an issue with the posts, can you post the linky? Maybe its a problem with the theme itself, which theme are you on? I'm asking all these cause I'm talking from my mobile and really cant properly see the full version of your blog.
I also had this same problem and my solution was to create a plugin to automate this! Check out this link: http://www.askapache.com/404-not-found-seo-12-11.html The plugin can be found on WordPress.org at AskApache Google 404 and more information can be found at the plugin page. Let me know if this works for ya
Interesting. However, consider this scenario. Someone browsing the internet finds my site. They visit my site through the google link. The Google link brings them to the 404 page. With this plugin, it appears that more Google search results would be displayed on the 404 page as possible alternatives. Now, what if those alternatives linked to more pages which are 404 ? The internet surfer would be frustrated at finding the 404 page to begin with and frustrated again when the "solution" bring him or her to another 404 page. I would be nice if the keyterm bringing them to my site would be passed through the blog's built-in search engine and listed as "Closely related links" . I think Google could be made aware of those closely related links in association with the 404..
Because a redirect (301) would not tell the search engines to remove older content. A 404 will get older links out of the search engines results ... eventually. A 301 will simply keep all "not found" links alive.
If you don't want your 404's indexed by google then add this to your header.php <?php if(is_404())echo '<meta name="robots" content="noindex" />';?> Code (markup): Another thing: When a request to wordpress is made for a non-existing post, it is run through the file canonical.php which automatically tries to find the requested post, using mispellings etc.. And really for SEO you shouldn't allow google to index your 404 pages. It could very well be that your blog is not returning the proper 404 Not Found http status code, which is a big problem in my humble point of view. You can check your blog for this with this http header viewer OK! I just took a 20minute break from writing this reply to go update the plugin.. I've just released version 4.4 (should show up in about 20minutes when svn repos update) which includes a new function that displays related posts on your blog! It searches for related posts using the keywords it finds from the requested url, and displays those as well as the google search. This fixes your question I believe? Thanks for the tip!
Ok, what I did was this in header.php <?php if(is_404())echo '<meta name="robots" content="noindex" /> '; else echo '<meta name="robots" content="follow, all" /> '; ?> Code (markup): In this manner, all pages except for 404 pages will be indexed.
Is it possible to strip out the category name from the permalink on the inbound link (e.g., "/category/the-post-inside" ... becomes "the-post-inside") and transform the dashes to spaces (e.g., "the-post-inside" becomes "the post inside")? Right now, the category name, and all URI information, is automatically placed in the Google search bar. Is there any method to remove the category (or everything up until the slash), and transform the dashes? Thanks.
Ok, here's what I'm attempting to do on the 404 page. <?php $search_term = substr($_SERVER['REQUEST_URI'],1); $search_term = urldecode(stripslashes($search_term)); $find = array ("'.html'", "'.+/'", "'[-/_]'") ; $replace = " " ; $search_term = trim(preg_replace ( $find , $replace , $search_term )); $search_term_q = preg_replace('/ /', '%20', $search_term); ?> Code (markup): What that code is supposed to do is capture the inbound link from the search engine, remove the slashes and the dashes, and create a new "wordpress friendly" search phrase for the search engine built into wordpress. I would love to prefill the search bar with the new search string.. <p> <form method="get" id="searchform" action="http://WWW.MYSITE.COM/"> <div> <input type="text" value="<?php echo $search_term_q; ?>" name="s" id="s" > <input type="submit" id="searchsubmit" value="Search" > </div> </form> </p> Code (markup): Can anyone spot what would be wrong with the first php coding? I can't seem to pass the value of $search_term_q to the search bar automatically.
Ok, I found some code on the 'net, and it helped me with what I wanted to do. This code will remove slashes and dashes. <?php $uri = $_SERVER['REQUEST_URI']; $uri = rtrim($uri, '/'); $new_string = str_replace("/", " ", $uri ); $final_string = str_replace("-", " ", $new_string); ?> Code (markup): And the new string will be placed inside a search box automatically, ... now the user has to click the search button. <p> <form method="get" id="searchform" action="http://WWW.MYSITE.COM/"> <div> <input type="text" value="<? echo $final_string; ?>" name="s" id="s" > <input type="submit" id="searchsubmit" value="Search" > </div> </form> </p> Code (markup): Now the goal is to run that newly formatted string and run an automatic search on it and display it on the page as a "You might have been looking for this..."
But I have a question here. I checked my WP blog directory in my account, I found 2 files with the name header.php. The first one was being located in my /blog/ directory, named [ wp-blog-header.php ] , and the other one was being located in my /themes/THEMESNAME/ directory, named [ header.php ] .. So which one should I add the code quoted above into ? Thanks in advance for your help.
I would start off with the one located in your themes directory. After you change something and save it, reload the page and browse the page's source code to identify the changes.
@AidenChong Nite is right! Never modify any files other than the ones in your theme and plugin directory, those are wordpress core files, and shouldn't be modified unless you know what you are doing. @Nite Heres what I am actually using: if(is_home() && !is_paged())$aa_robot_meta='<meta name="robots" content="noydir,follow" />'; else if(is_paged()) $aa_robot_meta='<meta name="robots" content="follow" />'; else if(is_search()) $aa_robot_meta='<meta name="robots" content="noindex,nocache,follow" />'; else if(is_page()) $aa_robot_meta='<meta name="robots" content="noydir,follow" />'; else if(is_single()) $aa_robot_meta='<meta name="robots" content="noydir,follow" />'; else if(is_category()) $aa_robot_meta='<meta name="robots" content="noindex,follow" />'; else if(is_404()) $aa_robot_meta='<meta name="robots" content="noindex,follow" />'; echo $aa_robot_meta; Code (markup):
Thanks @Nite @apachehtaccess , for clarifying my doubts. By the way, apachehtaccess, I have downloaded your wordpress 404 pages plugin, and you seems to have a very interesting blog too, keep up the good work, my friend.. Will visit your forum soon