Support » Plugins and Hacks » [Resolved] Showing Related Posts, Wrong Revision URL

[Resolved] Showing Related Posts, Wrong Revision URL

  • The related posts links are linking to non posts, seen this in other plugins that are years old, the problem is the database table that holds the posts and pages also holds revisions of posts and some plugins add their own post types. This wasn’t an issue years ago (before revisions), so wasn’t an issue when this plugin was created.

    Very easy fix, specify the item pulled must be a post or page, code fix below, I also add post_status is published as well.

    . "AND (post_type = 'post' OR post_type = 'page') "
    		 . "AND post_status = 'publish' "

    Add to copyfeed.php here

    // Primary SQL query
    	$sql = "SELECT ID, post_title, post_content,"
    		 . "MATCH (post_name, post_content) "
    		 . "AGAINST ('$terms') AS score "
    		 . "FROM $wpdb->posts WHERE "
    		 . "MATCH (post_name, post_content) "
    		 . "AGAINST ('$terms') "
    		 . "AND post_date <= '$now' "
    		 . "AND (post_status IN ('publish', 'static') "
    		 . "AND (post_type = 'post' OR post_type = 'page') "
    		 . "AND post_status = 'publish' "
    		 . "AND ID != $post->ID) ";

    This will stop links to revisions etc… otherwise you’ll find backlinks to pages that don’t exist and get a bunch of 404 errors in Google Analytics.

    If you have “Include similar content in feed?” ticked check your sites article feed, hover over the related links and you’ll find some will link to number URLs (these are revisions), some might lack anchor text. The above fixes this. You can also have this issue when you have Custom Menus, the links are stored in the same table and the slug can be generated by the title of the link rather than the actual posts slug.

    Great plugin BTW, I use it for gaining backlinks from autobloggers etc…



Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘[Resolved] Showing Related Posts, Wrong Revision URL’ is closed to new replies.