{"id":5889393,"date":"2015-03-11T23:56:52","date_gmt":"2015-03-11T23:56:52","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/my-related-posts-php-code-is-showing-unrelated-posts\/"},"modified":"2016-08-22T17:56:42","modified_gmt":"2016-08-22T17:56:42","slug":"my-related-posts-php-code-is-showing-unrelated-posts","status":"closed","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/my-related-posts-php-code-is-showing-unrelated-posts\/","title":{"rendered":"My related posts php code is showing unrelated posts"},"content":{"rendered":"<p>A while ago I tried to create my own related post functionality by using a tutorial and adding code to single.php. Unforunately most articles covered relation based on tags. I do not use tags so I want random articles from that same sub category.<\/p>\n<p>I have modified the code to the following:<br \/>\nhttp:\/\/pastebin.com\/yhiCYuTq<\/p>\n<p>Unfortunately 50% of the time it is showing completely unrelated posts from completely different categories! <\/p>\n<p>Is there anyone more experienced with WordPress and Php that can see what I  did wrong?<\/p>\n<p>regards<\/p>\n<p>ps You can check the result here: http:\/\/www.gameplayinside.com\/<\/p>\n","protected":false},"template":"","class_list":["post-5889393","topic","type-topic","status-closed","hentry","topic-tag-php","topic-tag-single-php"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/5889393","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/5889393\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=5889393"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}