Jump to content
zouleo

Custom Post Loop Content using the default template

Recommended Posts

zouleo

Basically I have a sql query that selects about 50 posts from the database based on certain criteria. What I'm wonder is if it is possible to display all these posts on a page using the default template for post the post loop.

What I have done so far is to make a plugin that inserts the list in any post based on a shortcode [myspecialposts]. And then I do a sql query to fetch the posts. But how do I display each post using the default themplate?

This is my code:

function myspecialposts_func( $atts ) {

global $wpdb;

global $post;

$sql = "SELECT {$wpdb->posts}.* ...";

$myposts = $wpdb->get_results($sql, OBJECT);

foreach ($myposts as $post) : setup_postdata($post);

		 // display each post using default template. HOW?

endforeach;

add_shortcode( 'myspecialposts', 'myspecialposts_func' );

Basically I want to use the get_article() function in the PageLinesPosts class. Is that possible?

Please help.

Share this post


Link to post
Share on other sites
Danny

HI,

I think the best course of action would be to create a custom loop section based on the Postloop section and add your criteria to the code.


Please search our forums, before posting!

Share this post


Link to post
Share on other sites
zouleo

Thanks for the suggestion. But the postloop section is almost empty:

$theposts = new PageLinesPosts();

$theposts->load_loop();
Would it be possible to insert that code after my code? Like this:
$myposts = $wpdb->get_results($sql, OBJECT);


$theposts = new PageLinesPosts();

$theposts->load_loop();

Or exactly what are you suggesting? :)

Share this post


Link to post
Share on other sites
Danny

Well PHP isn't my forte. Therefore, I recommend if you need further assistance, you contact one of our Pros - http://www.pagelines.com/pros/


Please search our forums, before posting!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


×