D
D
Dmitry2017-11-20 15:21:18
metadata
Dmitry, 2017-11-20 15:21:18

How to display news by wordpress tag?

I have a car portal, and for some reason I decided to use tags instead of car brand categories, now I want to create a page for each brand where there is a description, logo, etc., and below all the news for this tag. How to implement it?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Y
Yuri Kirillov, 2017-11-20
@kirilloff-iura

Tag output: Add to Functions.php to include a visual editor (hence attaching images) in labels:

remove_filter( 'pre_term_description', 'wp_filter_kses' );
remove_filter( 'term_description', 'wp_kses_data' );

function mayak_category_description($container = ''){
  $content = is_object($container) && isset($container->description) ? html_entity_decode($container->description) : '';
  $editor_id = 'tag_description';
  $settings = 'description';		
  ?>
    <tr class="form-field">
  <th scope="row" valign="top"><label for="description">Описание</label></th>
  <td><? wp_editor($content, $editor_id, array(
        'textarea_name' => $settings,
        'editor_css' => '<style>.html-active .wp-editor-area{border:0;}</style>',
  )); ?><br />
  <span class="description">Описание по умолчанию не отображается, однако некоторые темы могут его показывать.</span></td>
    </tr>
    <?	
}
add_filter('edit_category_form_fields', 'mayak_category_description');
add_filter('edit_tag_form_fields', 'mayak_category_description');

function mayak_remove_category_description(){
    global $mk_description;
    if ( $mk_description->id == 'edit-category' or 'edit-tag' ){
    ?>
        <script type="text/javascript">
        jQuery(function($) {
            $('textarea#description').closest('tr.form-field').remove();
        });
        </script>
    <?
    }
}
add_action('admin_head', 'mayak_remove_category_description');

Tag description output:
<? $posttags = get_the_tags();
if($posttags) foreach($posttags as $tag) echo $tag->description ?>

Loop for tag.php file :
<? while(have_posts()): the_post();
// содержимое записи
endwhile; 
?>

D
Dmitry, 2017-11-20
@Harlam2521

Here is a live example with actors only
govoru.com/celebrity/kevin-spacey

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question