wordpress 通过the_title()和get_the_title函数获取文章标题
2014-08-25 09:31
330 查看
the_title() 输出或返回当前文章标题。此标签用在主循环里。如果此文章是受密码保护的或者是私有的,
就会在文章标题前标记上"Protected:"或者"Private:"字样。
用法: <?phpthe_title( $before, $after, $echo ); ?>
参数:
$before 字符串型,标题之前放置的文本,默认是空
$after 字符串型,标题之后放置的文件,默认是空
$echo 逻辑型,true表示显示标题,false表示返回它并用在PHP中,默认为true.
示例:
<?phpthe_title('<h3>','</h3>'); ?>
get_the_title()通过文章ID返回文章标题。如果此文章是受密码保护的或者是私有的就会在文章标题前标记上"Protected:"或者"Private:"字样。
用法:<?phpecho get_the_title(ID); ?>
示例:
eg1:
<?php
query_posts('cat=1');
$dropdown="<selectname='dropdown'>";
while(have_posts()):the_post();
$dropdown.="<optionvalue='".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 ('<ahref="'.get_permalink($post->post_category).'"title="'.$parent_title .'">'.$parent_title.'</a>»');
}
?>
<a href='<?php the_permalink()?>' rel='bookmark' title='<?phpthe_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文件。
就会在文章标题前标记上"Protected:"或者"Private:"字样。
用法: <?phpthe_title( $before, $after, $echo ); ?>
参数:
$before 字符串型,标题之前放置的文本,默认是空
$after 字符串型,标题之后放置的文件,默认是空
$echo 逻辑型,true表示显示标题,false表示返回它并用在PHP中,默认为true.
示例:
<?phpthe_title('<h3>','</h3>'); ?>
get_the_title()通过文章ID返回文章标题。如果此文章是受密码保护的或者是私有的就会在文章标题前标记上"Protected:"或者"Private:"字样。
用法:<?phpecho get_the_title(ID); ?>
示例:
eg1:
<?php
query_posts('cat=1');
$dropdown="<selectname='dropdown'>";
while(have_posts()):the_post();
$dropdown.="<optionvalue='".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 ('<ahref="'.get_permalink($post->post_category).'"title="'.$parent_title .'">'.$parent_title.'</a>»');
}
?>
<a href='<?php the_permalink()?>' rel='bookmark' title='<?phpthe_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文件。
相关文章推荐
- wordpress 通过get_the_excerpt和the_excerpt函数获取文章摘要
- WordPress 如何通过ID获取文章标题、内容等信息
- WordPress通过文章ID获取文章标题内容等信息。
- GetConsoleTitle 函数--获取控制台窗口标题
- WordPress 通过文章ID获取文章标题、内容等信息
- wordpress 使用get_the_category 和get_term_link 获取文章分类 最简单的办法
- wordpress 通过文章ID 获取文章标题等信息
- 通过 SHGetSpecialFolderLocation、SHGetPathFromIDList 函数获取常用路径
- 黄聪:WordPress通过文章ID获取调用返回文章URL地址链接
- WordPress中用于获取文章信息以及分类链接的函数用法
- 内存管理[5]通过 GetProcessHeaps 函数获取了当前进程的堆句柄列表
- [转载]通过PsGetCurrentProcess函数获取函数名
- WordPress 显示文章摘要:the_excerpt标签函数
- PHPCMS使用get标签获取文章列表过滤重复标题并实现分页
- 详解WordPress开发中get_header()获取头部函数的用法
- WordPress获取所有页面的id函数: get_all_page_ids
- WordPress教程:如何使用the_title()与the_title_attribute()函数
- 小函数控制Wordpress的文章标题长度
- 通过 SHGetSpecialFolderLocation、SHGetPathFromIDList 函数获取常用路径
- 在Wordpress的文章页面获取上一页及下一页的链接URL地址,实现通过键盘的前进后退键进行翻页