Tag: wordpress预览模式: 普通 | 列表

wordpress调用指定分类文章如何实现

wordpress是很强大的cms系统,你可以通过相关函数就能实现相关的功能。很多网友会问wordpress怎么调用指定分类文章的呢?其实很简单,随ythah一起来看看吧,几行代码就解决了,代码如下

1
2
3
4
5
6
<ul>
<?php query_posts('cat=1&showposts=5'); //cat是要调用的分类ID,showposts是需要显示的文章数量 ?>
<?php while (have_posts()) : the_post(); ?>
<li><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></li>
<?php endwhile; wp_reset_query(); ?>
</ul>

是不是很方便?当然css样式可以自己定义

如果想从第二篇开始调用可以加一个参数&offset=1,第三篇开始调用就用&offset=2,以此类推

Tags: wordpress

分类:技术文章 | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 157

 描述

将分类以列表的形式显示为链接。点击分类的链接,就可以访问该分类下的所有文章的存档页面。

注意: wp_list_categories() 和 list_cats() 以及 wp_list_cats() 的使用类似,但是后面 2 个已经弃用。

如果你希望不格式化输出分类,请使用 get_categories()

查看更多...

Tags: wordpress

分类:技术文章 | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 141

wordpress调用当前分类的全部子分类

wordpress在制作企业主题的时候比较常遇到要调用当前分类下的全部子分类。要实现这个可以按照以下步骤操作。

首先在主题的“functions.php”里面写个函数,代码如下:

PHP代码
  1. // 获取子分类  
  2. function get_category_root_id($cat){  
  3.     $this_category = get_category($cat);  
  4.     while($this_category->category_parent) {  
  5.         $this_category = get_category($this_category->category_parent);  
  6.     }  
  7.     return $this_category->term_id;  
  8. }  

然后在需要调用的页面里写以下代码:

PHP代码
  1. <?php  
  2. if(is_category()) {  
  3.     $cat = get_query_var('cat');  
  4.     $categoryurl = get_category_link($cat);  
  5.     if(get_category_children(get_category_root_id(the_category_ID(false)))!= "" ) {  
  6.         echo wp_list_categories("child_of=".get_category_root_id(the_category_ID(false)). "&depth=0&hide_empty=0&title_li=&orderby=id&order=ASC");  
  7.     }  
  8. }  
  9. ?>  

最后自己调整下css就ok了。

Tags: wordpress

分类:技术文章 | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 154

Wordpress数据恢复用到的一些代码

 接前一篇文章:mysql根据.frm和.ibd文件恢复表结构和数据

数据库只要.ibd文件完整就可以恢复数据,.frm文件不需要。

数据库建表:

--
-- 表的结构 `wp_commentmeta`
--

查看更多...

Tags: wordpress mysql

分类:技术文章 | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 68
<rewrite>
      <rules>
<rule name="WordPress: http://www.tyzqwl.com/blog" patternSyntax="Wildcard">
<match url="*"/>
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true"/>
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true"/>
</conditions>
<action type="Rewrite" url="index.php"/>
</rule></rules>
    </rewrite>

Tags: wordpress

分类:技术文章 | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 68

wordpress内容分页代码

 <!--nextpage-->

Tags: wordpress

分类:技术文章 | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 77

Wordpress - IIS伪静态规则

这是适用于IIS7及以上的Wordpress的伪静态规则,保存成web.config文件,放到网站根目录即可。
<?xml version="1.0" encoding="UTF-8"?>
    <configuration>
        <system.webServer>
            <rewrite>
                <rules>
                    <rule name="WordPress" stopProcessing="true">
                        <match url="^(.*)$" />
                        <conditions>
                            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                        </conditions>
                        <action type="Rewrite" url="index.php" appendQueryString="true" />
                    </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

Tags: wordpress php

分类:技术文章 | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 701

 广告位

↑返回顶部↑