我们有时需要根据实际需要进行一些设置,比如wordpress调用指定分类除外的置顶文章,如何实现呢?随ytkah一起来看看吧,用如下代码插入到需要调取的位置 <div class="recommended-container"> <div class="title"><strong>RECOMMENDED</strong></div> <div class="box"> &l…
wordpress是很强大的cms系统,你可以通过相关函数就能实现相关的功能.很多网友会问wordpress怎么调用指定分类文章的呢?其实很简单,随ythah一起来看看吧,几行代码就解决了,代码如下 <ul> <?php query_posts('cat=1&showposts=5'); //cat是要调用的分类ID,showposts是需要显示的文章数量 ?> <?php while (have_posts()) : the_post(); ?> <li…
前面的文章wordpress调用指定分类文章如何实现有网友回复要如何调用指定tag的文章,原理是类似的,有两种方法,随ytkah一起来看看 1.第一种 <?php $args=array( 'tag_id' => 82,//指定id 'posts_per_page' => 5,//每页显示多少 ); query_posts($args); if(have_posts()) : while (have_posts()) : the_post(); ?> <li> //内容…
有时我们在开发wordpress时需要调用置顶文章sticky_posts,怎么调用呢?几种写法,有用到query_post的,有用到WP_Query,也有用到is_sticky(),下面随ytkah一起来看看吧 第一种调用置顶文章的方法,用到query_post,代码如下 <?php $query_post = array( 'posts_per_page' => 10, 'post__in' => get_option('sticky_posts'), 'caller_get_pos…
在 WordPress入门 之 发布新文章和管理文章 中,倡萌已经简单提到可以在文章编辑界面或者快速编辑界面设置置顶文章,但是如果你想在后台文章列表中添加一键置顶文章的功能,不妨试试 Quick Sticky 或 SM Sticky Clicky Star 插件. Quick Sticky 和 SM Sticky Clicky Star 都是用来给后台文章列表添加一键置顶文章功能的,一个较大的不同是,SM Sticky Clicky Star 支持 Ajax 无刷新设置,而 Quick Stic…
/*首页调用指定分类下的销售排行*/ function get_cats_top10($cat = '') { $sql = 'SELECT cat_id, cat_name ' . 'FROM ' . $GLOBALS['ecs']->table('category') . "WHERE parent_id = '$cat' ORDER BY sort_order ASC, cat_id ASC LIMIT 3"; $res = $GLOBALS['db']->getAl…
未测试 1.includes/lib_goods.php文件.把SQL语句改一下,与category表关联即可 将 $sql = 'SELECT g.goods_id,g.goods_name, g.goods_name_style, g.market_price, g.shop_price AS org_price, g.promote_price, ' . 改为 $sql = 'SELECT g.goods_id,g.cat_id,c.parent_id,g.goods_name, g.go…
举例如首页调用方法: 1.先打开index.php文件找到以下代码: $smarty->assign('new_articles', index_get_new_articles()); // 最新文章 在它下面增加以下: //调用方法$smarty->assign('class_articles_4', index_get_class_articles(4,6)); // 分类调用文章 //调用多个就修改传进去的参数,以及模板接收的变量,其中上面的4就是文章分类ID,其中6是调用数量 $sm…
第一步:--------------------------------------------------------------------------------------/** * 取指定分类ID及类型的商品信息 * @access public * @param string $cat_id 分类ID * @param string $num 显示商品数量 * @param string $cat_type 显示商品类型 new新品,hot热销,best为精品,promote特价 *…
wordpress很强大,可以添加多种post_type文章类型,假如我们要调用product产品模型的文章要如何操作呢?随ytkah一起来看看吧.我们用'post_type' => 'product'进行指定,代码如下 <?php $args = array( 'post_type' => 'product',//自定义文章类型名称 'showposts' => 5,//输出的文章数量,这个可以是缺省值,不用设置 'orderby' => 'rand',//按随机调用,如果…