Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8879903
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:03:29+00:00 2026-06-14T20:03:29+00:00

Firstly, sorry if this has been dealt with before, I’ve spent quite a while

  • 0

Firstly, sorry if this has been dealt with before, I’ve spent quite a while searching posts to no avail.

I have a WordPress blog and a Concrete5 site. I am trying to write out the three most recent WordPress blog posts on the Concrete5 site. I cannot use RSS as both sites are on the same server and internal RSS is disabled (is there a way to get around this?).

I have written a block for concrete and have put this code in view.php …

<?php 
   define('WP_USE_THEMES', false);
   require('path-to-wordpress/wp-blog-header.php');
?>

… This results in “Error establishing a database connection”.
If I run this outside of Concrete it works fine (I’m currently using this code elsewhere on the server, no probe).
I’ve also tried with wp_load.php, same result.

Sorry if this is really obvious, I’ve been working on it for a while now 🙁
Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T20:03:29+00:00Added an answer on June 14, 2026 at 8:03 pm

    Sadly this simple approach to loading WordPress does not work in concrete for whatever reason, some kind of conflicting definition or something. If you are trying to load WordPress posts on a Concrete5 site on the same server you might well find that using RSS will not work for you as sometimes servers block internal requests to prevent looping.

    This is the position I found myself in so I decided to access the WordPress table myself building on code posted by ‘jcrens8392’ on the Concrete5 forums , so here it is for anyone who finds them self in the same position.

    // posts and stuff
    $category = 3
    $items = 4
    
    // wordpress db stuff
    $dbUser = 'user';
    $dbPass = 'password';
    $dbHost = 'localhost';
    $dbName = 'name';
    
    
    // connect to wordpress database
    $conn = mysql_connect($dbHost, $dbUser, $dbPass);
    
    
    // handle connection errors
    if(!$conn) {
        $aDebug['Unable to connect to DB'] = mysql_error();
    } elseif(!mysql_select_db($dbName, $conn)) {
        $aDebug['Unable to select database'] = mysql_error();
    }
    
    
    // make SQL query
    else {
        $sQuery = "SELECT wp_posts.post_date, wp_posts.post_content , wp_posts.guid , wp_posts.post_title, wp_posts.post_excerpt, wp_posts.post_name FROM wp_posts , wp_term_relationships WHERE post_type = 'post' AND post_status = 'publish' AND wp_posts.ID = wp_term_relationships.object_id AND wp_term_relationships.term_taxonomy_id = ".$category." ORDER BY post_date DESC LIMIT ".$items;
        $rPosts = mysql_query($sQuery, $conn);
    }
    
    
    // plonk posts into a convinient array
    $posts = array();
    while($row = mysql_fetch_array($rPosts)){
            $excerpt = $controller->getExcerpt( utf8_encode( strip_tags( $row['post_content'] ) ) , 0 , 200 ) .' <a href="'.$row['guid'].'">Read More &#8594;</a>';
            $date = $controller->simplifyDate( $row['post_date'] );
            $temp = array ( 'post_title' => $row['post_title'] , 'post_excerpt' =>  $excerpt , 'post_date' => $date , 'post_link' => $row['guid'] );
            array_push( $posts , $temp );
        }
    

    I put these functions in controller.php (excerpt function from phpsnaps)…

    function getExcerpt($str, $startPos=0, $maxLength=100) {
        if(strlen($str) > $maxLength) {
            $excerpt   = substr($str, $startPos, $maxLength-3);
            $lastSpace = strrpos($excerpt, ' ');
            $excerpt   = substr($excerpt, 0, $lastSpace);
            $excerpt  .= '...';
        } else {
            $excerpt = $str;
        }
    
        return $excerpt;
    }
    
    
    function simplifyDate($str) {
        $months = array("January","February","March","April","May","June","July","August","September","October","November","December");
        $strs = split ( ' ' , $str );
        $date = split ( '-' , $strs[0] );
        $month = $months[ $date[1] - 1 ];
        $day =  $date[2];
        $year = $date[0];
        return $day . ' ' . $month . ' ' . $year;
    }
    

    This really isn’t the ideal solution, it does, however, have the distinct advantage of working. Hope this helps someone.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Firstly I asked sorry if this is a stupid question. but I have a
Firstly sorry if this is a common question but I couldn't find anything on
Firstly sorry for the long piece of code pasted below. This is my first
Firstly, sorry for my English (I'm from China). By reading this article( how to
Firstly, sorry if my title doesn't quite explain the situation, I had problems thinking
Firstly, I have migrated my CVS repository into SVN repository. I checked out this
Firstly, Kohana's documentation is terrible, before people go read the docs I have read
Possible Duplicate: Direct casting vs 'as' operator? Firstly I am sorry if this is
Firstly, very sorry if this is not a true stackoverflow question. But it's something
Firstly, sorry about the wall of text. I have the following schema. Note that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.