Support » Fixing WordPress » Category and pages being added to links

  • Hi all,

    Thanks in advance for any assistance people may offer.

    The problem:
    I have been entering links manually on my posts and pages, some for recommendations (products) and some to older posts of mine and other peoples. I always double check every link before publishing page or posts.

    I’ve just run a broken link checker and found 1,000’s of links that have had category/page/category/category/ added to them, leaving me with 1,000’s of broken links.

    Any ideas please?

    Regards, Barry

Viewing 4 replies - 1 through 4 (of 4 total)
  • 1) You should be able to use a “Find and replace” plugin to scan for a particular broken path. So /category/category/ can be changed to /category/

    2) Get a 404 page setup in your template.

    Hi Phill, thanks for your reply.

    There are loads of different variations of the links so I fear find and replace may be to long winded…. I’m currently working through old posts and removing dead links from them and the comments but I don’t think that’ll fix the issue mentioned above.

    Can you point me towards a guide for setting up a 404 page please?

    Barry

    Basically you make a 404.php in your top level of your template.

    http://codex.wordpress.org/Creating_an_Error_404_Page

    What you put in there is ip to you however…
    If your good with PHP you could use the explode function to take the URL and break it down to its key words and then search your WP site for those key words.

    Try something like this if 404 then search WP

    Then explode using the / as a break
    $_SERVER[‘PHP_SELF’] returns path /category/page etc

    $myurl=$_SERVER['PHP_SELF'];
    
    $keywords = explode("/",$myurl);
    
    foreach($keywords as $key){
    $searchstring=$searchstring.' '.$key;
    }
    
    header("Location: http://www.example.com/?q=$searchstring");

    Thanks Phill, I’ll look into sorting that out as soon as I’ve finished the spring clean 🙂

    Barry

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Category and pages being added to links’ is closed to new replies.