WordPress.org

Forums

Wp Subcribe Author
[resolved] Display subscribed authors' posts on a specific page (3 posts)

  1. twowarm
    Member
    Posted 1 year ago #

    Here's my code:

    global $wpdb;
    		global $current_user;
    
    		$table_name = $wpdb->prefix . "wpsa_subscribe_author";
    
    		get_currentuserinfo();
    		$post_author_id = $current_user->ID;
    
    		$subscribers = $wpdb->get_results($wpdb->prepare("SELECT author_id FROM $table_name WHERE subscriber_id = %d AND status = %s", $post_author_id, 'active'));
    
    		foreach ($subscribers as $subscriber) {
    			$a = array($subscribers[0]->author_id);
    			array_push($a, $subscriber->author_id);
    		}
    
        $paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1;
    		//$wp_query = new WP_Query(array('author__in' => $a, 'paged' => $paged));
    
    $wp_query = new WP_Query(array(
    'author__in' => $a,
    'paged' => $paged,
    'post_type' => array( 'post', 'comedy' ),)
    );
    
    if (have_posts()) : while (have_posts()) : the_post(); ?>

    Only two authors' posts show up if I subscribe more than two authors.
    Here's my site: http://itransl.com/subscription/

    Can you tell me why?

    https://wordpress.org/plugins/wp-subscribe-author/

  2. twowarm
    Member
    Posted 1 year ago #

    global $wpdb;
    	global $current_user;
    
    	$table_name = $wpdb->prefix . "wpsa_subscribe_author";
    
    	get_currentuserinfo();
    	$post_author_id = $current_user->ID;
    
    	$subscribers = $wpdb->get_results($wpdb->prepare("SELECT author_id FROM $table_name WHERE subscriber_id = %d AND status = %s", $post_author_id, 'active'));
    
    	foreach ($subscribers as $subscriber) {
    		$a = array($subscribers[0]->author_id);
    		array_push($a, $subscriber->author_id);
    
                    print_r($a);
    
    	}
    
    	$the_query = new WP_Query(array('author__in' => $a));
    
    if ($the_query->have_posts()) {
    		while ($the_query->have_posts()) : $the_query->the_post(); ?>
    			<li>
    				<h3><a href="<?php the_permalink(); ?>"><?php echo wp_trim_words(get_the_title(), 14, ""); ?></a></h3>
    			<>
    		<?php
    		endwhile;
    		wp_reset_postdata();
    	}

    The array is :
    Array ( [0] => 3688 [1] => 3688 ) Array ( [0] => 3688 [1] => 3692 ) Array ( [0] => 3688 [1] => 3691 ) Array ( [0] => 3688 [1] => 73 ) Array ( [0] => 3688 [1] => 3687 )

    How do I change it to:

    Array ( [0] => 3688 [1] => 3692 [2] => 3691 [3] => 73 [4] => 3687 )

  3. gchokeen
    Member
    Plugin Author

    Posted 10 months ago #

    This feature is added on the plugin with short code help!

    Display subscriber favourite author posts using this shortcode [favourite-author-posts] - VERION 1.6.5

    Thanks
    Gowri

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Wp Subcribe Author
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic

Tags

No tags yet.