SHOW:
|
|
- or go back to the newest paste.
1 | global $posts, $wpdb; | |
2 | ||
3 | if ( is_single() ) { | |
4 | $page_keywords = get_the_tag_list('', ' ', ''); | |
5 | } | |
6 | elseif (is_home() || is_category() || is_tag() || is_date() || is_search() ) { | |
7 | foreach ($posts as $post_values) { | |
8 | $array_id[] = $post_values->ID; | |
9 | } | |
10 | $list_id = implode('","', $array_id); | |
11 | $sql_query = 'SELECT DISTINCT name '. | |
12 | 'FROM '.$wpdb->term_relationships.' AS rel,'. | |
13 | $wpdb->term_taxonomy.' AS tax,'. | |
14 | $wpdb->terms.' AS ter '. | |
15 | 'WHERE tax. taxonomy = "post_tag" '. | |
16 | 'AND rel.object_id IN ("'. $list_id.'") '. | |
17 | 'AND rel.term_taxonomy_id = tax.term_taxonomy_id '. | |
18 | 'AND tax.term_id = ter.term_id ORDER BY tax.count'; | |
19 | $results = $wpdb->get_results($sql_query); | |
20 | - | if ($results) : |
20 | + | if ($results) { |
21 | $page_keywords = implode(' ', $results); | |
22 | - | else : ?> |
22 | + | } else { ?> |
23 | <script type="text/javascript"> | |
24 | alert ("The $results variable is empty."); | |
25 | </script> | |
26 | - | <?php endif; ?> |
26 | + | <?php } |
27 | } | |
28 | if ($page_keywords != '') { | |
29 | $page_keywords = htmlspecialchars(stripslashes(strip_tags(str_replace("\n", '', $page_keywords)))); | |
30 | echo '<meta name="keywords" content="'.$page_keywords.'">'."\n";' |