Skip to content

Instantly share code, notes, and snippets.

@wpweb101
Created January 27, 2014 13:39
Show Gist options
  • Save wpweb101/8648712 to your computer and use it in GitHub Desktop.
Save wpweb101/8648712 to your computer and use it in GitHub Desktop.
Follow Posts Listing
<?php
global $wpw_fp_options;
$prefix = WPW_FP_META_PREFIX;
// get all custom post types
$post_types = get_post_types( array( 'public' => true ), 'objects' );
$followtext = $wpw_fp_options['follow_buttons']['follow'];
$followingtext = $wpw_fp_options['follow_buttons']['following'];
$unfollowtext = $wpw_fp_options['follow_buttons']['unfollow'];
?>
<style type="text/css">
.wpw-fp-follow-posts-wrap {
display: inline-block;
margin: auto auto 0;
padding: 0 20px 0 0;
}
</style>
<h3><?php _e( 'Posts I Follow', 'wpwfp' ); ?></h3>
<?php
foreach ( $followposts as $followpost ) {
$post_parent = isset( $followpost['post_parent'] ) && !empty( $followpost['post_parent'] ) ? $followpost['post_parent'] : '';
if( !empty( $post_parent ) ) { // Check post parent is not empty
$posts = get_post( $post_parent );
// Get Follow Post Name
$post_name = isset( $posts->post_title ) ? ' ' . $posts->post_title : '';
$args = array(
'post_id' => $post_parent,
'current_post_id' => $post_parent,
'follow_message' => '',
'follow_buttons' => array(
'follow' => trim( $followtext ) . $post_name,
'following' => trim( $followingtext ) . $post_name,
'unfollow' => trim( $unfollowtext ) . $post_name,
),
);
?>
<div class="wpw-fp-follow-posts-wrap">
<?php do_action( 'wpw_fp_follow_post', $args ); ?>
</div>
<?php
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment