Only show Pro users posts with network latest posts?

Hi,

I have a working page that is showing the latest posts from all across my network. (see http://bloggerspoint.dk/bar-test) Now, i want it only to show posts from our Pro and Elite users (paid users from Pro Sites plugin), but I can't figure out why..

My current settings code looks like this: http://pastebin.com/wurj6Jm1

Can you help?

  • Ash
    • WordPress Hacker

    Okay, I have made some modifications: http://pastebin.com/cTiSDDw1

    Also, the code should show only level 1 as you have this:

    "SELECT * FROM {$wpdb->base_prefix}pro_sites WHERE level = 1"

    If you want to show all pro site posts, then try this:

    "SELECT * FROM {$wpdb->base_prefix}pro_sites"

    Hope it helps :slight_smile: Please feel free to ask more question if you have any.

    Cheers
    Ash

  • Ash
    • WordPress Hacker

    Hello @Mathias

    Would you please try this one?
    http://pastebin.com/PWzqh0Gs

    I have tried to implement all three into one based on shortcode:

    [globalproposts pro_level="all"] or [globalproposts] // Will show posts from all pro level
    [globalproposts pro_level="1"] // Will show posts from level ID 1
    [globalproposts pro_level="2"] // Will show posts from level ID 2
    [globalproposts pro_level="3"] // Will show posts from level ID 3
    and so on...

    I have not tested yet though, but I think it will work :slight_smile:

    Hope it helps :slight_smile: Please feel free to ask more question if you have any.

    Cheers
    Ash

  • Mathias
    • The Bug Hunter

    I used to use this code:

    function display_pro_posts_shortcode($atts, $content = null, $code = "") {
    
    		$defaults = array(	'number'	=>	98,
    							'title_characters' => 35,
    							'content_characters' => 50,
    							'title_content_divider' => '<br />',
    							'title_before'	=>	'<div>',
    							'title_after'	=>	'</div>',
    							'global_before'	=>	'<ul>',
    							'global_after'	=>	'</ul>',
    							'before'	=>	'<li class="crop-square">',
    							'after'	=>	'</a></li>',
    							'title_link' => 'yes',
    							'show_avatars' => 'no',
    							'show_images' => 'yes',
    							'avatar_size' => 16,
    							'posttype' => 'post',
    							'pro_level' => 'all'
    						);

    to control how many posts that were shown. Is it possible to make it maybe show 50 posts when showing all posts, when only showing pro and only showing elite? If i make it 50 now, it will only add 50 posts when showing all, and then showing 25 on each pro site level..

  • Jude
    • DEV MAN

    Hi there @Mathias

    The only problem is that the Pro prost (level 1) shows first and the Elite (level 2) shows after. I want it just to show them together.

    You mean randomly ? I have a small function here that can randomize anything on the DOM.
    Try it out, its JS you need to add and in your case explicity pass the li.crop-square class to it. I have updated my original code for you here

    jQuery( document ).ready(function() {
        jQuery("#div1").randomize("ul", "li.crop-square");
    });

    If i make it 50 now, it will only add 50 posts when showing all, and then showing 25 on each pro site level

    I am not sure if I fully understand this, can you explain ? If you want to control how many of each category to display you can try something like

    [globalproposts pro_level="all" number="50" ]
    [globalproposts pro_level="1" number="25" ]
    [globalproposts pro_level="2" number="15" ]
    [globalproposts pro_level="3" number="10" ]

    Hope that helps

    Cheers
    Jude

    • Mathias
      • The Bug Hunter

      If you visits the site: http://www.bloggerspoint.dk/bar-test/ you can see all the posts, with "Pro" and "Elite" sorting options. The problem is that it first show the latest Pro posts (level 1), and the Elite posts (level 2) after. Try sorting by "pro" and "elite". You will see when you select "pro" that the images won't change, but there will just be a cut off in the posts, so half of them is gone (the elite posts).

      I am sorry, if it is a bad explaining, but I think it is as good as I can.

  • Mathias
    • The Bug Hunter

    Sorry to create a new post, but.. I just want it to show only the Elite posts when the site loads, and then the user have to choose the Pro posts from the shortscode. See the sorting button on the page.
    Also, I want to make the button active with that blue color, same as the hover, when it is selected - is it even possible?

    Sorry for all the posts.

  • Jude
    • DEV MAN

    Hi there @Mathias

    You will see when you select "pro" that the images won't change, but there will just be a cut off in the posts, so half of them is gone (the elite posts).

    You can use some nice front end scripts like this one here or here

    Is that what you want ?

    can I then make it autoload more post when you scroll down? Is it too advanced to make?

    This is an excellent library that does this for you .

    Also here is a WordPress plugin that can set this effect up. Microsoft Bing use the library for their image search

    http://www.infinite-scroll.com/

    I want to make the button active with that blue color, same as the hover, when it is selected - is it even possible?

    You can use this CSS to do it

    button.showSingle {
    background: #0BB8E9;
    }

    Cheers
    Jude

    • Mathias
      • The Bug Hunter

      1. No, i just want to show posts from both Pro and Elite. Right now all the Pro posts comes first, and you have to scroll down to see the Elite posts. I just want the latest post from both pro sites levels (1 and 2) to be shown on the page together.

      2. I don't have any idea of how to use that - I am not a professional.

      3. When I use that CSS, it just makes my buttons blue all the time. I just want to make them blue, when they are active.

      Is it possible to get Ashok into this again? I think he knows better what I am trying to achieve here. He helped me a lot before.

  • Ash
    • WordPress Hacker

    Hello @Mathias

    I hope you are well today.

    Please use the following code to in your theme's footer.php after wp_footer():

    $(document).ready(function($){
          $('#div4 ul').each(function(){
                // get current ul
                var $ul = $(this);
                // get array of list items in current ul
                var $liArr = $ul.children('li');
                // sort array of list items in current ul randomly
                $liArr.sort(function(a,b){
                      // Get a random number between 0 and 10
                      var temp = parseInt( Math.random()*10 );
                      // Get 1 or 0, whether temp is odd or even
                      var isOddOrEven = temp%2;
                      // Get +1 or -1, whether temp greater or smaller than 5
                      var isPosOrNeg = temp>5 ? 1 : -1;
                      // Return -1, 0, or +1
                      return( isOddOrEven*isPosOrNeg );
                })
                // append list items to ul
                .appendTo($ul);
          });
    });

    This highly recommended to use a child theme in this case, as the changes will be lost when you will update the theme. You can learn more about child theme here: http://codex.wordpress.org/Child_Themes

    Hope it helps :slight_smile: Please feel free to ask more question if you have any.

    Cheers
    Ash

  • Ash
    • WordPress Hacker

    Hello @Mathias

    The above code should randomize the whole lists in that page. So, it won't be like one level first and another level second, the list items will be shuffled. (to do in php what you want, will need a fair amount of custom code)

    Anyway, if you remove my code, are the images back? I can see you are using lazy loader and also I am seeing a js error in the site. The error comes from x-head.min.js file. Do you know why is this file needed? If from any plugin, would you please disable that plugin?

    Cheers
    Ash

  • Mathias
    • The Bug Hunter

    Yes the images are back when i remove the code. It is removed now.

    The x-head.min.js file is from my themes folder. I have tried removing it, but that doesn't seem to do anything.

    This isn't the most important part, I can always figure this out later. If possible, I just want it to show only Elite posts (level 2) when the site loads. If the users want to see the Pro posts (level 1) they can click the "Pro" button in the bottom bar. And reverse, if they want to see Elite posts, they click "Elite".

    One thing i can't figure out is how to make the "Pro" and "Elite" buttons blue, when active. When Elite posts are shown, the "Elite" button is blue, and when Pro posts are shown, the "Pro" button is blue. I can only figure out to make it blue on hover (as it is right now).

    Here's the CSS for the /bar-test page: http://pastebin.com/pewQG3R5

  • Ash
    • WordPress Hacker

    Hello @Mathias

    I hope you are well today.

    I am sorry for the delay in your thread and but the delay was not intentional. Thank you so much for your patience.

    Would you please send me login details and FTP details?

    To send me details, please use our contact form: https://premium.wpmudev.org/contact/

    Select: I have a different question
    Subject: Attn-Ash (this ensures that it will be assigned to me)
    Details:
    1. Send all requested details (admin and FTP)
    2. Send a link of this thread so that I can track
    3. Send any other relevant link

    I will be happy to take a look :slight_smile:

    Cheers
    Ash

  • Ash
    • WordPress Hacker

    Hello @Mathias

    I hope you are well today.

    One thing i can't figure out is how to make the "Pro" and "Elite" buttons blue, when active. When Elite posts are shown, the "Elite" button is blue, and when Pro posts are shown, the "Pro" button is blue. I can only figure out to make it blue on hover (as it is right now).

    It seems the user you sent me doesn't have file uploading permission. It's always failed.

    Please use this in your css file:

    button.activeBtnFilter{
        background: #0bb8e9;
        border-style: none;
    }

    And the following in your functions.php:

    add_action( 'wp_head', 'wp_footer_cb' );
    function wp_footer_cb() {
    	?>
    	<script type="text/javascript">
    	jQuery(function($) {
    		$('button.showSingle').click(function() {
    			$('button.showSingle').removeClass('activeBtnFilter');
    			$(this).addClass('activeBtnFilter');
    		});
    	});
    	</script>
    	<?php
    }

    I can still see the js error from x-head.min.js file. As I could not upload so I could not check my above code though, but there are possibilities to not work as long the error from x-head.min.js file is not fixed.

    Please let me know about this.

    For your other issue, it will need a fair amount of custom code to do so. Also, you can post a job in our job board where you can hire a developer to assist further: https://premium.wpmudev.org/wpmu-jobs/ Please note that, no WPMU official staffs are allowed to work in the job board.

    Cheers
    Ash

  • Mathias
    • The Bug Hunter

    You should have capability to upload now, and your code works!

    You can't help me out, with only showing Elite posts when site loads? You have access to the plugin that controls the latest posts. It is the bp-b99ar folder in plugins.

  • Mathias
    • The Bug Hunter

    EDIT: Hey Ash. If possible, I want it either to show both posts from elite and pro together when site loads (mixed together, but not random - still sorted by date) or make the Elite button and posts active when the site loads, so only Elite posts are shown on load.

    • Mathias
      • The Bug Hunter

      Hi Ash,
      I am very sorry to reopen this thread, but i really need your help. I found out that i have to make it show the Elite posts first, because I use the plugin Lazy-load on all of our sites (netowork activated), and therefore also on the mainsite, as I can't only disable it on the mainsite.
      This mess up the front page a bit. Because I have only managed to trig a click, on the "Elite" button, when the site loads, and not actually to show the Elite posts when it loads. And when the Lazy-load plugin is activated, the images does not load, until you scroll down on the page.

  • Ash
    • WordPress Hacker

    Hello @Mathias

    I hope you are well today.

    Would you please add the following code in your theme's footer.php?

    <script type="text/javascript">
    jQuery(function($) {
      $('html, body').animate({scrollTop: '15px'}, 300);
    });
    </script>

    Please let me know if that works.

    Cheers
    Ash

  • Mathias
    • The Bug Hunter

    Hey Ash.
    I really need some help again here. I want to pull the Pro And Elite posts from our network and show them on the mainsite, and then link to their own posts in a new tab. Is this possible? I actually found this plugin https://wordpress.org/plugins/wordpress-mu-sitewide-tags/ that does the job, but it also transfer all the posts to the mainsite - and it should only be Pro and Elite posts.

    Is that possible, and can you help me out?

  • Mathias
    • The Bug Hunter

    I actually just want to show the posts, as if they were posted from the mainsite, but link to the post in a new window/tab, on the blog the posts is written from. You can take a look at the plugin i linked to in the previous post, as it does the job well, but it imports the posts to the mainsite (and still links to the right blog where the post is written), and that is not want I want. I just want it to link to the post, and only show Pro and Elite.

  • Mathias
    • The Bug Hunter

    Your code works, but i don't want to use shortcode. I use a magazine theme on my mainsite, and want it to show the latest posts from the network on the frontpage. Not using a shortcode. I don't know how else I can explain.
    If i can do that with your code, I don't know how.

  • Ash
    • WordPress Hacker

    Hello @Mathias

    As you said, that code works, you can call the shortcode in a template file. For example, if you used [globalproposts pro_level="1"] shortcode in content editor, use the following in template php file:

    <?php
    echo do_shortcode( '[globalproposts pro_level="1"]' );

    This is will do the same thing. Make sure you add the code from pastebin in your functions.php.

    Cheers
    Ash

  • Ash
    • WordPress Hacker

    Hello @Mathias

    Is the code already included before? When you see white page, would you please enable debug mode and check if any error is shown in that page?

    To enable debug mode please edit a line in your wp-config.php:
    Change

    define('WP_DEBUG', false);

    to

    define('WP_DEBUG', true);

    Please let us know what errors you see there.

    Cheers
    Ash

  • Ash
    • WordPress Hacker

    Hello @Mathias

    You don't want to use shortcode, then how do you want to show posts? You want to show in mainsite, but how? Either you have to use shortcode or you have to use template file. You have shortcode already, and I gave the template code to be used.

    Would you please explain your plan here? It will help you me to suggest :slight_smile:

    Cheers
    Ash

  • Mathias
    • The Bug Hunter

    I just want to show Them on the mainsite, but I don't know where to insert the code you gave me for template.
    I don't want to insert a shortcode and then style it, i just want to use the style of the theme, so that the posts shows up on the blogpage on the mainsite.

  • Ash
    • WordPress Hacker

    Ahh that means, you want to show those posts like an usual blog posts with proper pagination, right?

    In that case, it will need lots of custom code and you will need to use a different template page and assign that template to a page :slight_frown: Also, you can post a job in our job board where you can hire a developer to assist further: https://premium.wpmudev.org/wpmu-jobs/ Please note that, no WPMU official staff is available in the job board.

    Cheers
    Ash

    • Mathias
      • The Bug Hunter

      I am sorry for the misunderstanding, because of my (maybe) limited english.
      Have you looked at the plugin i linked to? I actually does the job, so I was wondering if it could be modified, so it only displayed posts from Pro and Elite?

  • Ash
    • WordPress Hacker

    Hello @Mathias

    I have checked the plugin, but it's not possible to customize the plugin when I am not totally familiar with that. Would you please ask the plugin developer if he can get us a clue in which file we should look to edit? Of if he can help?

    Cheers
    Ash

    • Mathias
      • The Bug Hunter

      Hi Ash - sorry to bother you with this thread again.

      I have added a category function/dropdown to the sorting bar in the bottom of http://www.bloggerspoint.dk, but it takes the categories of the mainsite, and I do not want that. I want it to show the categories from your/WPMU's Blog Category plugin, so the users can see their favorite categories.

      The code I am using for the category dropdown right now is this:

      <li>    <form id="category-select" class="category-select" action="<?php echo esc_url( home_url( '/' ) ); ?>" method="get">
      <?php
              $args = array(
                  'show_option_none' => __( 'Vælg kategori' ),
                  'show_count'       => 0,
                  'orderby'          => 'name',
                  'echo'             => 0,
              );
      ?>
      
              <?php $select  = wp_dropdown_categories( $args ); ?>
              <?php $replace = "<select$1 onchange='return this.form.submit()'>"; ?>
              <?php $select  = preg_replace( '#<select([^>]*)>#', $replace, $select ); ?>
      
              <?php echo $select; ?>
      
              <noscript>
                  <input type="submit" value="View" />
              </noscript>
  • Mathias
    • The Bug Hunter

    I have tried to post a job, but doesn't seem like anyone can do the job yet. Is it really advanced to make the mainsite do this?

    EDIT: Is it possible that we could use some of this:
    https://wordpress.org/support/topic/accessing-multisite-post-data-from-parent-site
    http://wordpress.stackexchange.com/questions/98965/get-posts-from-sites-in-multisite
    http://stackoverflow.com/questions/3884987/how-can-i-display-posts-from-the-other-sites-in-a-wordpress-multisite-setup

  • Vinod Dalvi
    • WP Unicorn

    Hi Mathias,

    I have tried to post a job, but doesn't seem like anyone can do the job yet.

    Why do you think so?

    If you can please share the job URL here that you have created so that we can help you whatever possible.

    Is it really advanced to make the mainsite do this?

    Actually developing custom code for custom functionality is beyond the scope of support that we provide. See here https://premium.wpmudev.org/manuals/using-wpmu-dev/support-vs-custom-development/ so we recommend you to hire a developer to do this for you.

    Any other issues, we're here to help.

    Thanks,
    Vinod Dalvi

  • Patrick
    • Support Monkey

    Hi there @Mathias

    Where can i find my own job posts?

    Unfortunately, there is currently no filter available to view only your own job postings. But if you would like to create a new topic in the Features & Feedback forum, our developers would be happy to look into the idea.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.