Not all blogs are appearing on Multisite Blog Query

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Not all blogs are appearing on Multisite Blog Query

This topic contains 4 replies, has 2 voices, and was last updated by LautaroAyosa LautaroAyosa 7 months, 2 weeks ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #36837
    LautaroAyosa
    LautaroAyosa
    Participant

    Hi! How are you doing?

    The issue is pretty simple, only 2 sites of the 6 that I have appear in the blog query of the “Multisite Options” tab. I need that all subsites appear and also I need that search box to search on all blogs.

    I have another issue, I have a plugin called Tikera to create events and sell tickets. I have duplicated all mainsite’s event categories to all my subsites (So I can use mainsite’s categories on all subsites, because subsite owners are not allowed to create new ones). The problem is that every category is (obviously) multiplied for the number of sites that have the category and the search box brings them all. Is there a way to search event categories only from the mainsite and get all sites data?

    Thank you for your help. Have a nice day.

    #36847
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi,

    Thank you for the details, it helps us a lot!

    For the blogs list, I made a correction via FTP, can you please confirm that all blogs are listed now? If so, then I will make sure integrate this patch in the next release.

    As for the categories, well there might be a way. It is not to prevent them from the search, but rather “remove” the ones from the results after the search is completed via a custom code.

    Try adding this code to the functions.php file in your theme/child theme directory – make sure to have a full server back-up first for safety. For more details you can check the safe coding guidelines.

    add_filter( 'asp_results', 'asp_custom_remove_results', 10, 1 );
    function asp_custom_remove_results( $results ) {
    	foreach ($results as $k=>&$r) {
    		if ( $r->content_type == 'term' && $r->blogid != get_main_site_id() ) {
    			unlet($results[$k]);
    		}
    	}
    
    	return $results;
    }

    This will check against each category type of result, if the source blog ID is the main site, and if not, then removes it.

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #36858
    LautaroAyosa
    LautaroAyosa
    Participant

    Thank you for your quick response!

    I’ve been testing a bit. Now Ajax search pro does show all subsites on the backend, but it doesn’t search in all of them. It only searches on the same 2 sites as before. (And obviously I get search results from only those 2 sites)

    Also, I’ve tried using the code that you provided to solve that thing with categories and taxonomies, but it doesn’t work. It throws a 500 error code when I try to search anything on the search bar.

    Thank you again for your help, hope we can solve this.

    #36862
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    It seems to be all right on my end at least. I tried an empty phrase to see what results do I get, and there are results from around the blogs: https://i.imgur.com/lORI3Zm.png

    Try this corrected custom code:

    add_filter( 'asp_results', 'asp_custom_remove_results', 10, 1 );
    function asp_custom_remove_results( $results ) {
    	foreach ($results as $k=>&$r) {
    		if ( $r->content_type == 'term' && $r->blogid != get_main_site_id() ) {
    			unset($results[$k]);
    		}
    	}
    
    	return $results;
    }
    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #36869
    LautaroAyosa
    LautaroAyosa
    Participant

    Ernest, hope you are doing great.

    Perfect! It works now. I saw the same thing as you did when I tested. When I entered an empty phrase the plugin returned me results from all subsites. But when I searched something in particular like “Gala” for example, it didn’t returned anything.

    Doesn’t matter tho, because it works now!

    Finally, the custom code works fine. It returns all events in that category.

    Thank you once more for the help. Have a nice week!

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.