Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*****************************************META FOR TAXONOMIES**************************************************************/
- // Редактирование мета поля
- function pippin_taxonomy_edit_meta_field($term) {
- // put the term ID into a variable
- $t_id = $term->term_id;
- // retrieve the existing value(s) for this meta field. This returns an array
- $term_meta = get_option( "taxonomy_$t_id" ); ?>
- <tr class="form-field">
- <th scope="row" valign="top"><label for="meta_title">МETA Title</label></th>
- <td>
- <input type="text" name="term_meta[title]" id="meta_title" value="<?php echo esc_attr( $term_meta['title'] ) ? esc_attr( $term_meta['title'] ) : ''; ?>">
- <p class="description"></p>
- </td>
- </tr>
- <tr class="form-field">
- <th scope="row" valign="top"><label for="term_meta[custom_term_meta]">META description</label></th>
- <td>
- <textarea name="term_meta[description]" id="meta_description" rows="4"><?php echo esc_attr( $term_meta['description'] ) ? esc_attr( $term_meta['description'] ) : ''; ?></textarea>
- <p class="description"></p>
- </td>
- </tr>
- <?php
- }
- add_action( 'category_edit_form_fields', 'pippin_taxonomy_edit_meta_field', 10, 2 );
- add_action( 'renter_type_edit_form_fields', 'pippin_taxonomy_edit_meta_field', 10, 2 );
- add_action( 'event_type_edit_form_fields', 'pippin_taxonomy_edit_meta_field', 10, 2 );
- // Сохранение метаполя
- function save_taxonomy_custom_meta( $term_id ) {
- if ( isset( $_POST['term_meta'] ) ) {
- $t_id = $term_id;
- $term_meta = get_option( "taxonomy_$t_id" );
- $cat_keys = array_keys( $_POST['term_meta'] );
- foreach ( $cat_keys as $key ) {
- if ( isset ( $_POST['term_meta'][$key] ) ) {
- $term_meta[$key] = $_POST['term_meta'][$key];
- }
- }
- // Save the option array.
- update_option( "taxonomy_$t_id", $term_meta );
- }
- }
- add_action( 'edited_category', 'save_taxonomy_custom_meta', 10, 2 );
- // define the aioseop_title callback
- function filter_aioseop_title( $title ) {
- if (is_tax()) {
- $t_id = get_queried_object()->term_id;
- $term_meta = get_option( "taxonomy_$t_id" );
- $title = $term_meta['title']!="" ? $term_meta['title'] : $title;
- //$title = "123";
- }
- return $title;
- };
- // add the filter
- add_filter( 'aioseop_title', 'filter_aioseop_title', 10, 1 );
- // define the aioseop_description callback
- function filter_aioseop_description( $description ) {
- if (is_tax()) {
- $t_id = get_queried_object()->term_id;
- $term_meta = get_option( "taxonomy_$t_id" );
- $description = $term_meta['description']!="" ? $term_meta['description'] : $description;
- }
- return $description;
- };
- // add the filter
- add_filter( 'aioseop_description', 'filter_aioseop_description', 10, 1 );
- /*****************************************end META FOR TAXONOMIES**************************************************************/
Add Comment
Please, Sign In to add comment