Skip to content

Instantly share code, notes, and snippets.

@jrthib
Created April 24, 2013 18:37
Show Gist options
  • Save jrthib/5454428 to your computer and use it in GitHub Desktop.
Save jrthib/5454428 to your computer and use it in GitHub Desktop.
Chunk of HTML code to query and output hero stories from custom post type, with advanced custom field values as well
<div id="hero" class="loading">
<ul class="slides">
<?php query_posts(array(
'post_type' => 'herostory',
'posts_per_page' => '-1'
));
while(have_posts()): the_post();
?>
<li>
<a href="<?php echo get_field('link_to'); ?>">
<img src="<?php the_field('hero_image'); ?>"/>
<span class="caption">
<span class="category"><?php the_field('topic'); ?></span>
<span class="heading"><?php the_title(); ?></span>
<span class="text"><?php
$content = get_the_content();
$content = str_replace(array('<p>', '</p>', '<br/>'), '', $content);
$content = preg_replace("/<a .*\">/", "<span class=\"link\">", $content);
$content = preg_replace("/<\a>/", "</span>", $content);
echo $content;
//echo strip_tags($content);
?></span>
</span>
</a>
</li>
<?php endwhile;
wp_reset_query();
?>
</ul>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment