网络营销电子商务研究中心  
How to buy the best prescription safety glasses in Canada? Let's study!
Go Back   网络营销电子商务研究中心 > 网站建设 > ZenCart
User Name
Password
 
FAQ Members List Calendar Cheap Glasses

Reply
 
Thread Tools Display Modes
  #1   IP: 153.99.80.189
Old 2016-08-17, 04:37 PM
Mahanoy City Mahanoy City is offline
初级会员
 
Join Date: 2009-02-07
Posts: 1
Mahanoy City 现在声名狼藉
Default Zen-cart 调用Wordpress文章方法

Zen-cart 有个WOZ的插件,作用就是调用Wordpress 的文章,将这个作为新闻系统来用。
其实,通过Wordpress自带的函数调用,完全可以达到同样的作用,下面介绍两种方法,一种是调用最新的文章;另一种是随机调用Blog文章。
首先,把WordPress安装到zen-cart一个子目录里,设置好固定连接等

一、调用最新文章
在合适的地方加入下面两行代码,一般会放在产品页面(/includes/templates/你使用的模板文件名/templates/tpl_product_info_display.php
<?php require('./wordpress所在目录/wp-blog-header.php'); ?> 这行调用WordPress自带函数,目录地址要随着WordPress安装目录变化而变化.如果你的Zen-cart不是根目录,那么前面就要打两个.['../wordpress所在目录/wp-blog-header.php']
<?php get_archives('postbypost', 10); ?> 这里的10指调用的最新文章数量

二、随机调用Blog文章
随机调用4篇Blog文章
<?php require('./wordpress所在目录/wp-blog-header.php'); ?>
<?php
$rand_posts = get_posts('numberposts=4&orderby=rand');
foreach( $rand_posts as $post ) :
?>
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php endforeach; ?>
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 2 (0 members and 2 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding a new Product Type in Zen Cart Illinois City ZenCart 0 2016-08-16 07:31 AM
What are the Server requirements to run Zen Cart? Mackinac Island ZenCart 0 2016-07-17 12:33 AM
How to Install an Zen Cart Template topvip ZenCart 0 2009-08-23 05:35 PM
X-Cart Multiple Input Validation Holes Permit SQL Injection and Cross-Site Scripting topvip X-Cart 0 2009-07-21 10:03 AM
x-cart Template Editing Guide for 4.1.x topvip X-Cart 0 2009-04-15 11:42 PM

Prescription-glasses.com offers prescription glasses online at discount prices.
All times are GMT +8. The time now is 10:59 AM.


Powered by vBulletin Version 3.8.7
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.