php - targeting and posting block quotes from posts -
my wordpress site's index.php has div posts title, category, , featured image of posts.
index.php html
<div> <h1><?php the_title(); ?></h1> <h3><?php the_category(' '); ?></h3> </div>
i have single.php brings in , puts content of post
single.php html
<div> <?php the_content(); ?> </div>
i want bring section of the_content of post index.php (for example in 'block quote' tag)
ex.
<div> <h1><?php the_title(); ?></h1> ... content block quote <h3><?php the_category(' '); ?></h3> </div>
you can retrieve content get_the_content()
, check if there's blockquote and, if so, echo it:
// content $content = get_the_content(); // check , retrieve blockquote if(preg_match('~<blockquote>([\s\s]+?)</blockquote>~', $content, $matches)) // output blockquote echo $matches[1];
Comments
Post a Comment