网络营销电子商务研究中心  
How to buy the best prescription safety glasses in Canada? Let's study!
Go Back   网络营销电子商务研究中心 > 网站建设 > WordPress
User Name
Password
 
FAQ Members List Calendar Cheap Glasses

Reply
 
Thread Tools Display Modes
  #1   IP: 112.87.85.4
Old 2015-06-14, 06:19 AM
Janessa Janessa is offline
初级会员
 
Join Date: 2006-07-12
Posts: 2
Janessa 现在声名狼藉
Default wordpress 通过the_title()和get_the_title函数获取文章标题

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> &raquo;');

}

?>

<a href='<?php the_permalink() ?>' rel='bookmark' title='<?php the_title(); ?>'>

<?php the_title(); ?></a> &raquo;

</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文件。
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

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

Prescription-glasses.com offers prescription glasses online at discount prices.
All times are GMT +8. The time now is 03:47 AM.


Powered by vBulletin Version 3.8.7
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.