网络营销电子商务研究中心

网络营销电子商务研究中心 (https://www.0058.net/index.php)
-   ZenCart (https://www.0058.net/forumdisplay.php?f=69)
-   -   zencart调用wordpress (https://www.0058.net/showthread.php?t=5842)

Macks Creek 2016-08-17 04:31 PM

zencart调用wordpress
 
调用最新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

Code:

    <!--  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指调用的最新文章数量


All times are GMT +8. The time now is 04:10 AM.

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