I’ve a follower button on customers profiles the place customers can observe different customers. I’ve a web page template that reveals all posts by customers the at the moment logged in consumer follows. I wish to create a shortcode [following_loop] for this as an alternative and add the question to the capabilities.php. I am unable to get the shortcode to work.
Right here is the web page template that I used to be utilizing. How can I get this into the shortcode?
perform register_shortcodes(){
add_shortcode('following_users', 'following_users_function');
}
add_action( 'init', 'register_shortcodes');
perform following_users_function () {
$currentloggedinuser = get_current_user_id();
// Get array containing solely the user_id1 values.
$followers = $wpdb->get_col(
$wpdb->put together(
"SELECT user_id1 FROM {$wpdb->prefix}followers WHERE user_id2 = %d",
$currentloggedinuser
)
);
type($followers); // or apply sorting within the question above
// Immediately echo the imploded array.
echo implode(', ', $followers);
$args = array(
'author__in'=> $followers, //use the array we received from the question
'post_type' => 'submit'
);
if (have_posts()) :
whereas (have_posts()) : the_post();
$return_string = '<a href="'.get_permalink().'">'.get_the_title().'</a>';
endwhile;
endif;
wp_reset_query();
return $return_string;
}
Thanks prematurely 🙂