This is searchable archive of our old support forums, which operated from 2012 - 2016. To find out how to get support for your current theme, please visit our support page.

content-404 template suggestions

  • Creator
    Topic
  • #1043
    fusionx22
    Participant

    Does anyone have any tips for customizing the content-404.php template? I’d like to add some more functionality, like give a list of related posts/pages, depending on how they arrived at the 404 page. For instance, if they came from Google, grab the keywords and do my own query, etc. Or, if they came from the site, grab the permalink, parse it, and do another query. Lastly, showing some featured/hand selected posts.

    Any other ideas for making this template more useful to the end users would be very welcome!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Author
    Replies
  • #1053
    Jason Bobich
    Keymaster

    Hello,

    Here are some general tips from the WordPress Codex on this subject if you’re interested: http://codex.wordpress.org/Creating_an_Error_404_Page

    I think some of things you’re describing aren’t really possible with the tools WordPress has by default. You can play with working with things like $_SERVER['HTTP_REFERER'], but I’m not sure how much you can really do with these things. I don’t think you can easily get as specific of information as you’re wanting to.

    It might be more realistic to think of some generic items to add like the last 5 posts from your blog, a search box to suggest searching for the page they’re looking for, maybe links to some of the more common pages on your site, etc.

    Here are some functions that might be useful:

    http://codex.wordpress.org/Function_Reference/get_search_form

    http://codex.wordpress.org/Template_Tags/get_posts

    http://codex.wordpress.org/Template_Tags/wp_list_pages

    #1059
    fusionx22
    Participant

    Hi Jason,

    Thanks for the info – the links are really helpful!

    I was thinking of checking the referrer, if present, and if Google/Yahoo/Bing, grabbing the search terms and query. For yahoo, the terms are in the p= parameter separated by a space. In Google’s referrer, it’s the q= separated by a + character. Not sure about Bing but it’s easy to find out. I know there are plug-ins that do this – maybe one has a short code I can use.

    If not, see if it came from my blog, and grab the permalink, parse it first on the “/” characters, then the “-” for the permalink terms, and query.

    Finally, default to some “featured” posts/pages/info and a search form. This is pretty easy, so that’s the first thing to do.

    If anyone else has any other ideas, please feel free to share!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The forum ‘Akita Responsive WordPress Theme’ is closed to new topics and replies.