How to get post thumbnails outside Wordpress? -
i need post title, date , content (or excerpt) of post thumbnail while getting url , image src separately. i'm working around query:
select * wp_posts post_type='post' , post_status='publish' order id desc limit 5
using query above, how posts thumbnail? i'm retrieving data way:
<?php #start loop starts $i @ 0, , make increase until it's @ number of rows for($i=0; $i< $num_rows; $i++) { #assign data variables, $i row number, increases each run of loop $blog_date = mysql_result($query_result, $i, "post_date"); $blog_title = mysql_result($query_result, $i, "post_title"); $blog_excerpt = mysql_result($query_result, $i, "post_excerpt"); $blog_content = mysql_result($query_result, $i, "post_content"); #$blog_permalink = mysql_result($query_result, $i, "guid"); //use line p=11 format. $blog_permalink = $blog_url . mysql_result($query_result, $i, "post_name"); //combine blog url, permalink title. use title format #format date $blog_date = strtotime($blog_date); $blog_date = strftime("%b %e", $blog_date); ?> <div class="post"> <div class="date"><?php echo $blog_date; ?></div> <h2><a href="<?php echo $blog_permalink; ?>"><?php echo $blog_title; ?></a></h2> <div class="entry"> <?php echo $blog_excerpt; ?> </div> </div> <?php } #ends loop ?>
thanks.
you can use wp_query outside of wordpress
like
<?php require( 'your_wordpress_root_folder/wp-load.php' ); $args = array( 'post_status' => 'publish', 'post_type' => 'post', 'posts_per_page' => 5 ); $query = new wp_query( $args ); while ( $query->have_posts() ) : $query->the_post(); ?> <h1><a href="<?php the_permalink() ?>"><?php the_title() ?></a></h1> <?php if ( has_post_thumbnail()) : ?> <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" > <?php the_post_thumbnail() ?></a> <?php endif; endwhile;
Comments
Post a Comment