PDA

View Full Version : zencart调用wordpress


Macks Creek
2016-08-17, 04:31 PM
调用最新4篇Blog文章
<?php require('./wordpress所在目录/wp-blog-header.php'); ?>
<?php
$rand_posts = get_posts('numberposts=4&orderby=post_date');
foreach( $rand_posts as $post ) :
?>
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a><br /><?php echo substr($post->post_content,0,200).'...';?></li>
<?php endforeach; ?>

Madalyn
2016-08-17, 04:33 PM
<!-- BOF Load Wordpress -->
<div class="sidebox-header-right "><h3 class="rightBoxHeading " id="Notification">Service Notification</h3></div>
<div id="bestsellersContent" class="sideBoxContent">
<div class="wrapper">
<?php require('./blog/wp-blog-header.php'); ?>
<?php
$rand_posts = get_posts('numberposts=3&orderby=post_date');
foreach( $rand_posts as $post ) :
?>
<a href="<?php the_permalink(); ?>"><font color="red"><?php the_title(); ?></font></a><HR align=center width=95% color=#987cb9 SIZE=1>
<?php endforeach; ?>
</div>
</div>
<!-- EOF Load Wordpress -->


这个你可以参考以下,是我自己用的。
numberposts=3&orderby=post_date 其中3代表要调用文章数目
内容太长了我不想调用了

以上部分代码放在 ../common/tpl_mail_page.php里
<div id="navColumnTwoWrapper" style="width: <?php echo BOX_WIDTH_RIGHT; ?>">
下面
那显示的结果就是右侧栏最上面

Madison Lake
2016-08-17, 04:34 PM
产品页面调用WordPress最新文章 已解决
把WordPress安装到zen-cart一个子目录里吧,设置好固定连接等
这个文件/includes/templates/template_default/templates/tpl_product_info_display.php在合适的地方加入下面两行代码

<?php require('../wordpress所在目录/wp-blog-header.php'); ?> 这行调用WordPress自带函数,目录地址要随着WordPress安装目录变化而变化
<?php get_archives('postbypost', 10); ?> 这里的10指调用的最新文章数量