![]() |
|
|||||||
![]() |
|
|
Thread Tools | Display Modes |
|
#1
IP: 112.87.85.4
|
|||
|
|||
|
the_title() 输出或返回当前文章标题。此标签用在主循环里。如果此文章是受密码保护的或者是私有的,
就会在文章标题前标记上"Protected:"或者"Private:"字样。 用法: <?php the_title( $before, $after, $echo ); ?> 参数: $before 字符串型,标题之前放置的文本,默认是空 $after 字符串型,标题之后放置的文件,默认是空 $echo 逻辑型,true表示显示标题,false表示返回它并用在PHP中,默认为true. 示例: <?php the_title('<h3>', '</h3>'); ?> get_the_title() 通过文章ID返回文章标题。如果此文章是受密码保护的或者是私有的就会在文章标题前标记上"Protected:"或者"Private:"字样。 用法:<?php echo get_the_title(ID); ?> 示例: eg1: <?php query_posts('cat=1'); $dropdown="<select name='dropdown'>"; while (have_posts()):the_post(); $dropdown.="<option value='".get_the_title()."'>".get_the_title()."</option>"; endwhile;wp_reset_query(); $dropdown.="</select>"; echo $dropdown; ?> eg2: <div class='breadcrumb'> <?php $parent_title = get_the_title($post->post_category); if($parent_title != the_title("<h3>","<h3>",false)) { echo ('<a href="'.get_permalink($post->post_category).'" title="'.$parent_title . '">'.$parent_title.'</a> »'); } ?> <a href='<?php the_permalink() ?>' rel='bookmark' title='<?php the_title(); ?>'> <?php the_title(); ?></a> » </div> Values $post->post_status $post->comment_status $post->ping_status $post->post_pingback $post->post_category $post->post_content $post->post_title $post->post_excerpt $post->page_template $post->post_parent $post->menu_order 源文件:the_title()和get_the_title()都在wp-includes/post-templete.php文件。 |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Simple Steps to Change Your Table Prefix in WordPress | Abby | WordPress | 0 | 2014-04-14 03:40 PM |
| Install WordPress on IIS | topvip | Blog(博客)/Wiki(维客)/RSS/Cms | 1 | 2010-01-25 08:31 PM |
| 让wordpress首页显示特殊页面(flash首页等) | yahoo | Blog(博客)/Wiki(维客)/RSS/Cms | 0 | 2009-02-25 06:58 AM |
| wordpress 搜索引擎优化的二十条实用技巧 | car | 搜索引擎优化 | 0 | 2008-03-11 08:33 AM |
| WordPress 中文包 | sunshine | Blog(博客)/Wiki(维客)/RSS/Cms | 0 | 2007-03-12 10:16 AM |