Hello,
I am using two different PHP scripts, one to access my MySQL database that my WordPress is hosted on, and another to grab the latest 12 posts and view them on the homepage.
The PHP script to access the database: [[wp-log]] Snippet
<?php
//db parameters
$db_username = '#########';
$db_password = '#########';
$db_database = '#########';
$db_host = '#########';
//connect to the database
mysql_connect($db_host, $db_username, $db_password);
@mysql_select_db($db_database) or die("Unable to select database");
//get data from database -- !IMPORTANT, the "LIMIT 5" means how many posts will appear. Change the 5 to any whole number.
$query = "Select * FROM wp_posts WHERE post_type='post' AND post_status='publish' ORDER BY post_date DESC LIMIT 12";
$query_result = mysql_query($query);
$num_rows = mysql_numrows($query_result);
//close database connection
mysql_close();
?>
I put that into a snippet called [[wp-log]] and then put it above all of the coding in my template (dak films) as [*wp-log*]
Then In the right column of my page I have the snippet [[l12p]] which has the following PHP code in it:
<?php
for($i=0; $i< $num_rows; $i++){
$blog_date = mysql_result($query_result, $i, "post_date");
$blog_title = mysql_result($query_result, $i, "post_title");
$blog_content = mysql_result($query_result, $i, "post_content");
$blog_permalink = mysql_result($query_result, $i, "id");
$blog_date = strtotime($blog_date);
$blog_date = strftime("%b %e", $blog_date);
?>
<li class="home-list"><a href='http://blog.dakfilms.org/?p=<?php echo $blog_permalink; ?>' target="_parent"><span class="date"><?php echo $blog_date; ?>:</span> <?php echo $blog_title; ?></a></li>
<?php
}
?>
This is used in my home page, not in the template, but in an actual page as [*l12p*].
Yet it does not show up.
This method does work if I do not use ModX and just simply have an index.php file with them in it.
Ex.
http://www.dakfilms.org (not a modx page)
http://www.dakfilms.org/index.php.modx (the modx page)
Any help would be greatly appreciated!! Thanks!!!