如何在wordpress中按页面ID设置页面标题

时间:2015-05-07 12:58:16

标签: php wordpress

我正在尝试在wordpress中设置页面标题。

假设在以博客为中心的网站中,每当我们点击标记时,都会打开一个新页面,其中包含该标记的所有帖子。我无法为这些页面设置页面标题。

应该有一个解决这个问题的方法,就像添加过滤器来按页面ID设置页面标题。我的意思是每当打开特定ID的页面时,它应该显示自定义标题。我怎么能这样做?

1 个答案:

答案 0 :(得分:0)

我遇到了同样的问题:

 <?php $tag_name = get_tags(array('slug'=>get_query_var('tag'))); ?>

            <?php if ( have_posts() ) :  ?>



                    <div <?php post_class(array('pin-article')); ?> >



                        <article class="article category">

                             <p><?php _e( 'Tag','wip'); ?> : <strong> <?php echo $tag_name[0]->name;  ?> </strong> </p>

                    </article>



                    </div>

             <?php if ( $wp_query->post_count > 1 ) : ?>



                          <div class="filter" data-filter="all"><?php _e( 'Show all','wip' ); ?></div>

                          <?php while ( have_posts() ) : the_post(); ?>

                          <?php $mixitTags = get_the_tags();?>  

                                <?php foreach($mixitTags as $k => $tag):

                                          if($tag->name != $tag_name[0]->name):

                                             $tagFilter[] = $tag->name;



                                          endif;

                                 endforeach;?>

                          <?php endwhile;?>

                          <?php 

                          $tagFilter = array_unique($tagFilter);



                          foreach ($tagFilter as $filter) :

                            echo '<div class="filter" data-filter=".'.sanitize_title($filter).'">'.$filter.'</div>';

                          endforeach ?>

              <?php endif; ?><!-- Fin de vérification si post > 1 -->
相关问题