douci4026 2013-12-18 01:07
浏览 111
已采纳

常数DB_PASSWORD Wordpress / Opencart

I am attempting to display the latest 3 posts from my blog, On my Opencart site.

The WP blog is at a subdomain blog.domain.com

I am adding this to footer.tpl in OC

<?php
require('/var/www/vhosts/blog.domain.com/wp-blog-header.php');
?>

But when i do this i get this error...

Notice: Constant DB_PASSWORD already defined in /var/www/vhosts/blog.domain.com/wp-config.php on line 29 Warning: mysql_connect(): Access denied for user '<>'@'localhost' (using password: YES) in /var/www/vhosts/blog.domain.com/wp-includes/wp-db.php on line 1036

From what i have been reading this is being caused by having 2 DB_PASSWORD defined, assuming that these would be 1 for WP and 1 for OC.

Is there anyway to work around this?

  • 写回答

1条回答 默认 最新

  • dongyu1983 2013-12-18 01:29
    关注

    To anyone that is looking for the answer to this later as @sammitch suggested using the RSS feed is a great way to do this here is a code snippet below.

    <?php
        $rss = new DOMDocument();
        $rss->load('<<URL TO RSS FEED>>');
        $feed = array();
        foreach ($rss->getElementsByTagName('item') as $node) {
        $item = array ( 
        'title' => $node->getElementsByTagName('title')->item(0)->nodeValue,
        'link' => $node->getElementsByTagName('link')->item(0)->nodeValue,
        );
        array_push($feed, $item);
        }
        $limit = 3;
        for($x=0;$x<$limit;$x++) {
        $title = str_replace(' & ', ' &amp; ', $feed[$x]['title']);
        $link = $feed[$x]['link'];
        echo '<li><a href="'.$link.'" title="'.$title.'" target="_blank">'.$title.'</a></li>';
        }
    ?>
    

    Probably worth mentioning that i only needed title and link from the array there is a lot of other variables that you can pull out.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题