• wordpress二次开发随笔-2


    调用分类,标签,友情连接,搜索框


    调用分类
    get_the_category()
    调用标签
    get_the_tags()
    调用友情连接
    wp_list_bookmarks()
    调用指定文章的ID,guid,标题,摘要,内容
    get_the_ID()
    get_the_guid(post_id)
    get_the_title(post_id)
    get_the_excerpt(post_id)
    get_the_content('','',8)
     
    调用搜索框
    get_search_form();
    html代码调用
    <form method="get" id="searchform" action="<?php bloginfo('url'); ?>/">
    <div>
    <input type="text" value="<?php the_search_query(); ?>" name="s" id="s" />
    <input type="submit" id="searchsubmit" value="Search" />
    </div>
    </form>
     
    搜索页代码
    <?php if ( have_posts() ) : ?>
    <?php while ( have_posts() ) : the_post(); ?>
    <div><a href="<?php echo get_permalink($post->ID); ?>">
    <?php the_title(); ?></a></div>
    <?php endwhile; ?>
    <?php else : ?>
    <article> <header class="entry-header">
    <h1 class="entry-title">
    <?php _e( '没有找到该文章', 'leizi' ); ?></h1> </header>
    <div class="entry-content"> <p>
    <?php _e( '抱歉没有找到该文章', 'leizi' ); ?></p>
    <?php get_search_form(); ?> </div> </article>
    <?php endif; ?>
     
    调用特色图片
    the_post_thumbnail(); 
    // 无参数,默认调用Thumbnail the_post_thumbnail( 'thumbnail' ); 
    // Thumbnail (默认尺寸 150px x 150px max) the_post_thumbnail( 'medium' ); 
    // Medium resolution (default 300px x 300px max) the_post_thumbnail( 'large' ); 
    // Large resolution (default 640px x 640px max) the_post_thumbnail( 'full' ); 
    // Full resolution (original size uploaded) the_post_thumbnail(  array (100,100) ); 
    // Other resolutions
     
    $getThumbnail = wp_get_attachment_image_src( get_post_thumbnail_id(get_the_ID()),full);
    echo $getThumbnail[0];
     
      
     
    __()函数和__e()函数被用来识别php文件中被标示的、需要被翻译成其它语言或本地化的字符串。
     
     
    两个函数间的唯一功能性区别在于:
     
    _e()函数回显(echo)返回的字符串,而__()函数只是返回字符串。如果需要为函数提供字符串,可使用__()函数。而如果希望将字符串作为XHTML的一部分输出,则需要使用_e()函数。
     

    站点信息调用


     

    echo get_bloginfo('name').
    echo get_bloginfo('description')
    echo get_bloginfo('admin_email').
    echo get_bloginfo('charset')
    echo get_bloginfo('version')
    echo get_bloginfo('language')
    echo get_bloginfo('wpurl')
    echo get_bloginfo('url')
    echo get_bloginfo('template_url')
     
     
     
    ‘name’ – 返回站点标题,站点标题通过后台控制面板 设置=》常规 中设置。
    ‘description’ – 返回站点副标题,站点副标题通过后台控制面板 设置=》常规 中设置。
    ‘wpurl’ – 返回站点URL
    ‘url’ – 返回站点地址。
    ‘admin_email’ – 返回站点设置的邮件地址
    ‘charset’ – 返回站点的字符。
    ‘version’ – 返回wordpress版本.
    ‘html_type’ – 返回wordpress页面的文档类型(default: “text/html”).
    ‘text_direction’ -返回wordpress站点额描述信息.
    ‘language’ – 返回wordpress的语言,中文版是zh_CN。
    ‘stylesheet_url’ – 返回主题style.css的绝对路径。
    ‘stylesheet_directory’ – 返回主题style.css的路径。
    ‘template_url’ / ‘模板目录’
    ‘pingback_url’ -返回站点 XML-RPC 文件的 URL (xmlrpc.php).
    ‘atom_url’ – 返回 Atom feed 地址 (/feed/atom).
    ‘rdf_url’ – 返回 RDF/RSS 1.0 feed 地址 (/feed/rfd).
    ‘rss_url’ – 返回 RSS 0.92 feed 地址 (/feed/rss).
    ‘rss2_url’ – R返回 RSS 2.0 feed 地址 (/feed).
    ‘comments_atom_url’ – 返回评论的 Atom feed URL (/comments/feed).
    ‘comments_rss2_url’ – 返回评论的 RSS 2.0 feed URL (/comments/feed).3
  • 相关阅读:
    Angular InjectionToken
    ionic 使用入门
    EFcore 横向分表
    .Netcore 默认认证授权
    anut 设计资源
    Aunt entity
    百度人脸真人认证
    Angular 省市区级联
    apache安装
    ppb|ppm
  • 原文地址:https://www.cnblogs.com/fslnet/p/15090931.html
Copyright © 2020-2023  润新知