Home > Blockchain >  Wordpress PHP get_results unexpected T_STRING
Wordpress PHP get_results unexpected T_STRING

Time:10-09

I am receiving a unexpected t_string when trying to use this function I made. I know I must be missing something here.

function get_top_terms(){
global $wpdb;
$termsSQL = "SELECT DISTINCT AN_terms.name from AN_posts INNER JOIN AN_term_relationships on AN_term_relationships.object_id = AN_posts.ID INNER JOIN AN_term_taxonomy on AN_term_taxonomy.term_taxonomy_id=AN_term_relationships.term_taxonomy_id INNER JOIN AN_terms on AN_term_taxonomy.term_id=AN_terms.term_id where AN_posts.post_date_gmt >= NOW() - INTERVAL 1 DAY and AN_term_taxonomy.taxonomy = "post_tag" group by AN_terms.name order by count DESC limit 5";
$tResults = $wpdb->get_results($termsSQL);
print_r($tResults);
}
add_shortcode ( 'topTerms', 'get_top_terms');

CodePudding user response:

try this one

function get_top_terms(){
global $wpdb;
$termsSQL = "SELECT DISTINCT AN_terms.name from AN_posts INNER JOIN AN_term_relationships on AN_term_relationships.object_id = AN_posts.ID INNER JOIN AN_term_taxonomy on AN_term_taxonomy.term_taxonomy_id=AN_term_relationships.term_taxonomy_id INNER JOIN AN_terms on AN_term_taxonomy.term_id=AN_terms.term_id where AN_posts.post_date_gmt >= NOW() - INTERVAL 1 DAY and AN_term_taxonomy.taxonomy ='post_tag' group by AN_terms.name order by count DESC limit 5";
$tResults = $wpdb->get_results($termsSQL);
print_r($tResults);
}

add_shortcode ( 'topTerms', 'get_top_terms');

a simple syntax error appears.

I just changed the 'post_tag' part

  • Related