WordPress.org

Support

Support » Plugins and Hacks » Hacks » Problem when include wordpress page in external website

Problem when include wordpress page in external website

  • Hello,

    I want to get the total number of posts from wordpress to my php website.
    So i use line require_once(‘c:/xampp/htdocs/wordpress/wp-blog-header.php’);

    There was no problem when I connected my database using “mysql_

    But the problem arrives when I change the database connection string from “mysql_” to “PDO”.

    I get Warning: PDOStatement::execute() [pdostatement.execute]: SQLSTATE[42S02]: Base table or view not found: 1146 Table ‘WORDPRESS_DB.MY_TABLE’ doesn’t exist

    So In my website, instead of my connection string, it uses the wordpress databse connection string.

    Please reply. How to solve this problem?
    Thanks.

Viewing 1 replies (of 1 total)
  • bcworkz
    Participant

    @bcworkz

    If all you want is a post count, I would not load the WP environment with wp-blog-header.php. That is a lot of overhead for a mere post count.

    Instead, connect to the WP database with PDO and run a count query on the posts table for records of post_type = ‘post’ AND post_status = ‘publish’

Viewing 1 replies (of 1 total)
  • The topic ‘Problem when include wordpress page in external website’ is closed to new replies.