Pedaç al plugin de posts relacionats

Fa temps vaig instal·lar el plugin de WordPress per tal que mostri els enllaços relacionats a un post, avui m’he adonat que té un forat important que fa que es mostrin els esborranys en aquest llistat d’enllaços.

Per reparar-ho només cal afegir un AND post_status = 'publish' allà on toca:

[ ... ]
function related($stuff='', $id) {
	global $wpdb, $table_prefix, $max_related;
        $stuff=addslashes($stuff);
	$sql = "SELECT ID,post_title,post_content,post_excerpt,post_date,
MATCH(post_title,post_content) AGAINST ('".$stuff."') AS score FROM
".$table_prefix."posts WHERE ID!=$id AND MATCH (post_title,post_content) AGAINST
('".$stuff."') ORDER BY post_date desc LIMIT 0,".$max_related;
[ ... ]

related.php original

[ ... ]
function related($stuff='', $id) {
	global $wpdb, $table_prefix, $max_related;
        $stuff=addslashes($stuff);
	$sql = "SELECT ID,post_title,post_content,post_excerpt,post_date,
MATCH(post_title,post_content) AGAINST ('".$stuff."') AS score FROM
".$table_prefix."posts WHERE ID!=$id AND MATCH (post_title,post_content) AGAINST
('".$stuff."') AND post_status = 'publish'  ORDER BY post_date desc LIMIT 0,".$max_related;
[ ... ]

related.php apedaçat

oriol

oriol wrote 1166 posts

Post navigation