function
ReadWPPosts() {
$path = $_SERVER[
'DOCUMENT_ROOT'
];
include_once $path .
'/wordpress/wp-load.php'
;
include_once $path .
'/wordpress/wp-config.php'
;
$db =
new
mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
if
(mysqli_connect_errno()){
exit(
"Couldn't connect to the database: "
.mysqli_connect_error());
}
$sql =
"select * from wp_posts"
;
$res = mysqli_query($db, $sql);
if
($res) {
while
($row = $res -> fetch_assoc()) {
$sql .=
"\n"
.$row[
"ID"
].
" "
.$row[
"post_title"
];
}
}
mysqli_close($db);
return
$sql . 'ok
';
}
add_shortcode('
GenReadPosts
', '
ReadWPPosts');