Created
June 28, 2009 00:15
-
-
Save zoranzaric/137162 to your computer and use it in GitHub Desktop.
include posts or gallerys from a wordpress into a php file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//this part is on the page from where you want to include the stuff from your wp | |
function include_wordpress($options) { | |
$domain = 'example.com'; | |
$script = 'wrapper.php?mode=album&album=AlbumName'; | |
$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_URL, $domain . '/' . $script); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | |
$output = curl_exec($ch); | |
curl_close($ch); | |
return $output; | |
} | |
$options = array("mode" => "album", "album" => "AlbumName"); | |
echo include_wordpress($options); | |
//check if $output is -1, then a you parameters where wrong | |
?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// wrapper.php | |
require_once('wp-blog-header.php'); | |
if($_GET['mode']=='cat' && isset($_GET['cat'])) { | |
$my_query = new WP_Query('category_name=' . $_GET['cat']); | |
while ($my_query->have_posts()) : $my_query->the_post(); | |
echo $post->ID; ?> | |
<!-- Do stuff... --> | |
<?php endwhile; | |
}elseif($_GET['mode']=='album' && isset($_GET['album'])) { | |
$showalbum = '[album=' . $_GET['album'] . ',compact]'; | |
$showalbum = apply_filters('the_content', $showalbum ); | |
echo $showalbum; | |
}elseif($_GET['mode']=='gal' && isset($_GET['gal'])) { | |
$showalbum = '[nggallery id=' . $_GET['gal'] . ']'; | |
$showalbum = apply_filters('the_content', $showalbum ); | |
echo $showalbum; | |
}else { | |
echo -1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment