wordpress常用标签整理

wordpress yekong 2209℃

公共标签

调用主题目录


<?php bloginfo('template_url'); ?>

调用主体样式


<?php bloginfo('stylesheet_url'); ?>

首页

获取指定分类链接


<?php
                $category_id = get_cat_ID('装修问答');
                $category_link = get_category_link($category_id);
                ?>
                <a href="<?php echo $category_link; ?>" title="装修问答">更多>></a>

调用指定分类的文章 cat 分类id posts_per_page调用文章数量


<?php
                $args = array(
                    'cat' => 82,
                    'posts_per_page' => 10,
                );
                query_posts($args);
                if (have_posts()) : while (have_posts()) : the_post(); ?>
                    <li>
                        <a href='<?php the_permalink(); ?>' title="<?php the_title(); ?>"><?php the_title(); ?></a>
                        <span class="pull-right"><?php the_time('yy-m-d') ?></span>
                    </li>

                <?php
                endwhile; endif;
                wp_reset_query();
                ?>

友情链接

需要友情链接插件 Link Manager


<?php wp_list_bookmarks('title_li=&categorize=0'); ?>

文章

面包屑导航 需要插件Breadcrumb NavXT。


<?php
    if (function_exists('bcn_display')) {
        bcn_display();
    }
    ?>

文章标题


<?php the_title(); ?>

发布日期


<?php the_time('yy-m-d') ?>

文章内容


<?php if (have_posts()) : ?>
            <?php while (have_posts()) : the_post(); ?>
                <?php the_content(); ?>
            <?php endwhile; ?>
        <?php else : ?>
        <?php endif; ?>

调用随机10篇文章


<?php
                query_posts(array('orderby' => 'rand', 'showposts' => 10));
                if (have_posts()) :
                    while (have_posts()) : the_post();?>
                        <li><a href="<?php the_permalink() ?>" target="_blank" title="<?php the_title(); ?>"><?php the_title(); ?></a></li>
                    <?php endwhile; ?>
                <?php endif; ?>
喜欢 (0)