Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- global $posts, $wpdb;
- if ( is_single() ) {
- $page_keywords = get_the_tag_list('', ' ', '');
- }
- elseif (is_home() || is_category() || is_tag() || is_date() || is_search() ) {
- foreach ($posts as $post_values) {
- $array_id[] = $post_values->ID;
- }
- $list_id = implode('","', $array_id);
- $sql_query = 'SELECT DISTINCT name '.
- 'FROM '.$wpdb->term_relationships.' AS rel,'.
- $wpdb->term_taxonomy.' AS tax,'.
- $wpdb->terms.' AS ter '.
- 'WHERE tax. taxonomy = "post_tag" '.
- 'AND rel.object_id IN ("'. $list_id.'") '.
- 'AND rel.term_taxonomy_id = tax.term_taxonomy_id '.
- 'AND tax.term_id = ter.term_id ORDER BY tax.count';
- $results = $wpdb->get_results($sql_query);
- if ($results)
- $page_keywords = implode(' ', $results);
- else : ?>
- <script type="text/javascript">
- alert ("The $results variable is empty.");
- </script>
- <?php endif; ?>
- }
- if ($page_keywords != '') {
- $page_keywords = htmlspecialchars(stripslashes(strip_tags(str_replace("\n", '', $page_keywords))));
- echo '<meta name="keywords" content="'.$page_keywords.'">'."\n";'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement