WordPress tags for/in wp_pages
Categories: PHP, Wordpress on Sep.06, 2008
Была задача прикрутить к страницам(wp_pages) теги, но на сегодняшний день они не групируются и не добавляются в облако и т.д.. Пришлось ковыряться в кривой административной части движка wordpress, где нет понятия разделяй и властвуй!
Стерпев безобразие все же сделал, то что требовалось!
Во первых вставляем код в фаил wp-includes/script-loader.php
1 2 3 4 5 6 7 8 9 | $this->add( 'page', '/wp-admin/js/post.js', array('suggest', 'jquery-ui-tabs', 'wp-lists', 'postbox', 'slug'), '20080318' ); $this->localize( 'page', 'postL10n', array( 'tagsUsed' => __('Tags used on this post:'), 'add' => attribute_escape(__('Add')), 'addTag' => attribute_escape(__('Add new tag')), 'separate' => __('Separate tags with commas'), 'cancel' => __('Cancel'), 'edit' => __('Edit'), ) ); |
вместо :
1 2 3 4 5 |
В файле вставим формочку wp-admin/edit-page-form.php после <h2><?php _e(‘Advanced Options’); ?></h2>
1 2 3 4 5 6 7 | <div id="tagsdiv" class="postbox <?php echo postbox_classes('tagsdiv', 'post'); ?>"> <h3><?php _e('Tags'); ?></h3> <div class="inside"> <p id="jaxtag"><input type="text" name="tags_input" class="tags-input" id="tags-input" size="40" tabindex="3" value="<?php echo get_tags_to_edit( $post_ID ); ?>" /></p> <div id="tagchecklist"></div> </div> </div> |
А так их можно отобразить:
1 2 3 4 5 6 | $tags = $wpdb->get_results("SELECT t.name as tag FROM $wpdb->terms as t, $wpdb->term_relationships as tr, $wpdb->term_taxonomy as tt, $wpdb->posts as p WHERE t.term_id=tt.term_id and tr.term_taxonomy_id=tt.term_taxonomy_id and tr.object_id=p.ID and tt.taxonomy='post_tag' and p.post_type='page' and p.ID=".$post->ID); foreach($tags as $tag) $t .= "<b>".$tag->tag."</b>, "; echo substr($t, 0, strlen($t)-2); |
Спасибо за внимание, чуть позже допишу эти таги и обязательно запостю вторую часть.
Similar posts:

(1 votes, average: 4.00 out of 5)
Оставить отзыв