Created
January 8, 2020 10:33
-
-
Save raviousprime/7cab3bb232e49ad288bad39204013d2b to your computer and use it in GitHub Desktop.
Modify buddyblog loop with theme loop
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
<?php if ( buddyblog_user_has_posted() ): ?> | |
<?php | |
//let us build the post query | |
if ( bp_is_my_profile() || is_super_admin() ) { | |
$status = 'any'; | |
} else { | |
$status = 'publish'; | |
} | |
$paged = bp_action_variable( 1 ); | |
$paged = $paged ? $paged : 1; | |
$query_args = array( | |
'author' => bp_displayed_user_id(), | |
'post_type' => buddyblog_get_posttype(), | |
'post_status' => $status, | |
'paged' => intval( $paged ) | |
); | |
//do the query | |
query_posts( $query_args ); | |
?> | |
<?php if ( have_posts() ): ?> | |
<?php while ( have_posts() ): the_post(); | |
global $post; | |
?> | |
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>> | |
<?php get_template_part( 'template-parts/post/content', get_post_format() ); ?> | |
<div class="post-actions"> | |
<?php echo buddyblog_get_post_publish_unpublish_link( get_the_ID() );?> | |
<?php echo buddyblog_get_edit_link();?> | |
<?php echo buddyblog_get_delete_link();?> | |
</div> | |
</div> | |
</div> | |
<?php endwhile;?> | |
<div class="pagination"> | |
<?php buddyblog_paginate(); ?> | |
</div> | |
<?php else: ?> | |
<p><?php _e( 'There are no posts by this user at the moment. Please check back later!', 'buddyblog' );?></p> | |
<?php endif; ?> | |
<?php | |
wp_reset_postdata(); | |
wp_reset_query(); | |
?> | |
<?php elseif ( bp_is_my_profile() && buddyblog_user_can_post( get_current_user_id() ) ): ?> | |
<p> <?php _e( "You haven't posted anything yet.", 'buddyblog' );?> <a href="<?php echo buddyblog_get_new_url();?>"> <?php _e( 'New Post', 'buddyblog' );?></a></p> | |
<?php endif; ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment