Posted By

Ben on 07/21/09


Tagged

php wordpress


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

irishsk


Wordpress query to pull a snippet from a post/page


 / Published in: PHP
 

This simply pulls 165 characters from a page/post. Important to reset the query.

  1. <?php query_posts('pagename=about'); ?>
  2. <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
  3. <div><h4>Type your title here</h4>
  4. <p><?php echo substr(strip_tags($post->post_content), 0, 165); ?>... <a href="<?php bloginfo('url'); ?>/about">Read More</a></p></div>
  5. <?php endwhile; endif;
  6. //Reset Query
  7. wp_reset_query();
  8. ?>

Report this snippet  

You need to login to post a comment.