Skip to content

Instantly share code, notes, and snippets.

@dkruchok
Created December 3, 2015 09:23
Show Gist options
  • Save dkruchok/991edb226b86a5176d65 to your computer and use it in GitHub Desktop.
Save dkruchok/991edb226b86a5176d65 to your computer and use it in GitHub Desktop.
Counter after p WP
<div class="frame">
<div class="post-content">
<?php if (!is_single() && of_get_option('of_excerptset')=='1') {
$image = wp_get_attachment_url( get_post_thumbnail_id($post->ID) ); ?>
<img src="<?php echo $image; ?>">
<?php the_excerpt(); ?>
<?php } else { ?>
<?php //Removed the original line below ?>
<?php //the_content( __('Read more', 'cr') );?>
<?php //Added this one insted: ?>
<?php //Shoe social buttons after first paragraph
$show_after_p = 0;
$content = apply_filters('the_content', $post->post_content);
if(substr_count($content, '<p>') > $show_after_p)
{
$contents = explode("</p>", $content);
$p_count = 0;
foreach($contents as $content)
{
echo $content;
if($p_count == $show_after_p)
{
?>
<?php if (is_single()) { echo do_shortcode("[easy-social-share]"); } ?>
<?php
}
echo "</p>";
$p_count++;
}
}
?>
<?php //remove the above ?>
<?php if(is_single()) { ?>
<div class="pagelink">
<?php wp_link_pages(); ?>
</div>
<?php } ?>
<?php } ?>
</div>
</div><!-- frame -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment