WordPress¿ª·¢ÖÐÓÃÓÚ±êÌâÏÔʾµÄÏà¹Øº¯ÊýʹÓýâÎö

5年以前  |  阅读数:371 次  |  编程语言:PHP 

single_cat_title()º¯Êý
single_cat_title()º¯Êý£¬ÈÕ³£ÖÐÎÒÃǺÜÉÙ»aÓõ½£¬µ«Õa¸oº¯Êý»a¸øÎÒÃǽa¾oºÜ¶aÎÊÌa£¬ÖiÈ統ǰҳÃaeµÄĿ¼¡¢±eÇ(C)£¬¸Ãº¯Êý²»ÒÀ¸½ÓÚ WordPress Ö÷Ñ­»ÖУ¬Ò²²»ÄÜÅÈeÖ÷Ñ­»*ÖÐʹÓá£

ÃeÊo
»ñÈ¡µ±Ç°Ò³ÃaeµÄ*ÖÀa¡¢±eÇ(C)¡£


     <?php single_cat_title($prefix,$display); ?>

  • $prefix :ÓÃÓÚÉeÖÃÔÚ±eÌa֮ǰÏÔʾµÄÄÚÈÝ¡£
  • $display £ºÓÃÓÚÉeÖÃÊÇÖ±½ÓÏÔʾ»¹ÊÇ*µ»Øµ½±aÁ¿¡£

ʵÀý
ÔÚ´Ëժȡ WordPress 2011 ĬÈÏÖ÷ÌaÖУ¬category.php Îļþ µÚ18ÐÐ×oÓÒλÖõĴuÂe


     <?php
    printf( __( 'Category Archives: %s', 'twentyeleven' ), '<span>' . single_cat_title( '', false ) . '</span>' );
    ?>

get_the_title ºÍ the_title
get_the_title ºÍ the_title Á½¸oº¯ÊýÓÃÀ´ÔÚÎÄÕÂÒ³ÃaeÏÔʾÎÄÕ±eÌaµÄº¯Êý£¬Ö®ËuÒÔ½«Á½¸oº¯ÊýºÏ²¢µ½Ò»ÆªÎÄÕÂÀiÃaeÈ¥ÊÇÒoΪÕaÁ½¸oº¯ÊÇÒ»¸oʵÏÖ£¬Ö»²»¹ý the_title ĬÈÏÖ±½ÓÏÔʾ£¬get_the_title ĬÈϵ»Ø×Öu´®£¬Èç¹uÄa¶Ô´ËÐÄ´aeÒÉ»o£¬ÄÇÇeÄaÍuÏ¿´¡£

º¯ÊýÏe½a
get_the_title ºÍ the_titleÕaÁ½¸oº¯ÊýÖ÷ÒªÓÃÓÚÔÚÑ­»ÖÐÏÔʾµ±Ç°ÎÄÕµıeÌa£¬Çe×¢Òa the_title Õa¸oº¯Êý±ØÐeʹÓÃÔÚÑ­»ÖС£
Á½ÕßµÄÇø±ðÔÚÓÚ£¬get_the_title½oÄÜÒÔ×Öu´®ÐÎʽµ»ØÎÄÕ±eÌa£¬¶ø the_title ¿ÉÒÔÉeÖñeÌaÇ°ºoµÄ×Ô¶¨Òa×Öu£¬ÒÔ¼°ÊÇÏÔʾ»¹Êǵ»Ø×Ö*u´®¡£

the_title º¯ÊýʹÓᢲÎÊýÏe½a


    <?php the_title( $before, $after, $echo ); ?>
  • $before±eÌaÇ°µÄ×Ö*u
  • $after±eÌaºoµÄ×Ö*u
  • $echoÏÔʾ¡¢»¹Êǵ»Ø×Öu´®£¬Ä¬ÈÏΪtrue

the_titleʾÀý


    <?php the_title( ¡®=>', ¡®<=' ); ?>

ÒÔ±¾ÎÄΪÀý£¬ÎÒÃǽ«µÃµ½ÒÔÏÂÕaÑuµÄ±eÌa£º


    ¡®=>get_the_title ºÍ the_title<='

get_the_title º¯ÊýʹÓᢲÎÊýÏe½a


    <?php $myTitle = get_the_title($ID); ?>

ÒÔÉÏ´uÂeÎÒÃǽ«µÃµ½ÎÄÕ±eÌaµÄ±aÁ¿$myTitle;
$ID ÓÃÓÚÉeÖÃÎÄÕ ID £¬µ±È»ÔÚÑ­»*ÖÐÎÒÃÇ¿ÉÒÔÊ¡ÂԴ˲ÎÊý¡£

get_the_title ʾÀý


    <?php
     $myTitle = get_the_title($ID); 
     echo $mytitle.'¡¾±eÌaÑÝʾ¡¿';
    ?>

ÎÒÃǽ«µÃµ½

get_the_title ºÍ the_title¡¾±eÌaÑÝʾ¡¿

×ܽa
˵ÁËÕaô¶a£¬²»ÖªµÀ¶ÔÄuÊÇñÓÐËu°iÖu£¿
×ܵÄÀ´Ëµ the_title ÊÇ get_the_titleµÄ¸u¸ßÒ»¼¶
a×°¡£¾ÍÏñÔÚ wp_titleÖÐ˵µÄÄÇÑu£¬¸u¸ß¼¶*a×°£¬ËaȻʹÓÃÆðÀ´¼oµ¥£¬µ«ÄÜÕÛÌÚ»¨ÑuÏa¶ÔÉÙÁ˵a¡£
ÏÂÃaeÊǸÃÁ½¸oº¯ÊýµÄÔ´´uÂe

the_title º¯ÊýÉuÃ÷
¸Ãº¯ÊýλÓÚ wp-include/post-template.php ÎļþµÄ 43 ¨C 55ÐÐ×oÓÒµÄλÖÃ


    <?php
    /**
     * Display or retrieve the current post title with optional content.
     *
     * @since 0.71
     *
     * @param string $before Optional. Content to prepend to the title.
     * @param string $after Optional. Content to append to the title.
     * @param bool $echo Optional, default to true.Whether to display or return.
     * @return null|string Null on no title. String if $echo parameter is false.
     */
    function the_title($before = '', $after = '', $echo = true) {
     $title = get_the_title();

     if ( strlen($title) == 0 )
     return;

     $title = $before . $title . $after;

     if ( $echo )
     echo $title;
     else
     return $title;
    }
    ?>

get_the_title º¯ÊýÉuÃ÷
¸Ãº¯ÊýλÓÚ wp-include/post-template.php ÎļþµÄ 103 ¨C 118ÐÐ×oÓÒµÄλÖÃ


    <?php
    /**
     * Retrieve post title.
     *
     * If the post is protected and the visitor is not an admin, then "Protected"
     * will be displayed before the post title. If the post is private, then
     * "Private" will be located before the post title.
     *
     * @since 0.71
     *
     * @param int $id Optional. Post ID.
     * @return string
     */
    function get_the_title( $id = 0 ) {
     $post = &get;_post($id);

     $title = isset($post->post_title) ? $post->post_title : '';
     $id = isset($post->ID) ? $post->ID : (int) $id;

     if ( !is_admin() ) {
     if ( !empty($post->post_password) ) {
      $protected_title_format = apply_filters('protected_title_format', __('Protected: %s'));
      $title = sprintf($protected_title_format, $title);
     } else if ( isset($post->post_status) && 'private' == $post->post_status ) {
      $private_title_format = apply_filters('private_title_format', __('Private: %s'));
      $title = sprintf($private_title_format, $title);
     }
     }
     return apply_filters( 'the_title', $title, $id );
    }
    ?>
 相关文章:
PHP分页显示制作详细讲解
SSH 登录失败:Host key verification failed
获取IMSI
将二进制数据转为16进制以便显示
获取IMEI
文件下载
贪吃蛇
双位运算符
PHP自定义函数获取搜索引擎来源关键字的方法
Java生成UUID
发送邮件
年的日历图
提取后缀名
在Zeus Web Server中安装PHP语言支持
让你成为最历害的git提交人
Yii2汉字转拼音类的实例代码
再谈PHP中单双引号的区别详解
指定应用ID以获取对应的应用名称
Python 2与Python 3版本和编码的对比
php封装的page分页类完整实例