BuddyDev

Search

Replies

  • Participant
    Level: Master
    Posts: 279
    NikB on in reply to: [Resolved] BuddyBlog Pro – exclude from recent posts #47490

    Hi Brajesh

    I think/hope it should work anywhere that Elementor Pro allows you to use a custom query, but I’ll get back to you if I come across anywhere that it doesn’t 😉

    Regards
    Nik

  • Participant
    Level: Master
    Posts: 279
    NikB on in reply to: [Resolved] BuddyBlog Pro – permalinks #47487

    Hi Brajesh

    Thank you and I did wonder if that should be the case.

    I will look out for an update in due course.

    Regards
    Nik

  • Participant
    Level: Master
    Posts: 279
    NikB on in reply to: [Resolved] BuddyBlog Pro – exclude from recent posts #47480

    Hi Brajesh

    Thank you so much. I’m pleased to report that both of the options you’ve suggested seem to work perfectly.

    In waiting for your reply, I’d also put together my own custom query for the Elementor posts widget along very similar lines and which I thought I would post here for reference and/or just in case it’s of interest to anyone else…

    add_action( 'elementor/query/my_custom', function( $query ) {
    // Get current meta Query
    	$meta_query = $query->get( 'meta_query' );
    
    	// If there is no meta query when this filter runs, it should be initialized as an empty array.
    	if ( ! $meta_query ) {
    		$meta_query = [];
    	}
    
    	// Append our meta query
    	$meta_query[] = [
    		'key' => '_bblgroups_group_id',
    		'compare' => 'NOT EXISTS',
    	];
    
    	$query->set( 'meta_query', $meta_query );    
    } );

    Note: I did wonder if I’d need to do the same for “Related Posts” widgets but so far I can’t find any evidence of group posts appearing as related to personal posts. Not sure if this is by luck or design(!) but I’ll monitor just in case.

    As always, many thanks for your assistance.
    Regards
    Nik

  • Participant
    Level: Master
    Posts: 279
    NikB on in reply to: [Resolved] BuddyBlog Pro – exclude from recent posts #47471

    Hi Brajesh

    Thank you for getting back to me. Yes I’m using the core WordPress recent posts widget on some of the pages so if you can let me know the code for that, it would be very helpful. (I’m also using Elementor but that allows you to use a custom query so if you can possibly give me the example for the core widget, I can probably figure this part out myself.)

    With many thanks in advance.
    Nik

  • Participant
    Level: Master
    Posts: 279
    NikB on in reply to: BuddyBlog Pro Posts Layout – 2 #47420

    Hi Brajesh

    Thank you for your thoughts and I will give them some consideration.

    Both BuddyBlog and Events Manager do what they’re designed to do really well, and my challenge all along has been to combine the best elements of both whilst presenting them in a coherent, user-friendly way (ideally with a single tab in the personal and group profiles).

    I think I’m still going to struggle to list entries which are, let’s say, “pending”, according to BuddyBlog using an EM shortcode but will definitely explore that option a bit more.

    I really am very grateful for all your support which I do appreciate is rather beyond the scope of your plugins themselves 😉

    Regards
    Nik

  • Participant
    Level: Master
    Posts: 279
    NikB on in reply to: BuddyBlog Pro Posts Layout – 2 #47415

    Oh dear… I spoke to soon.

    I edited query_posts as shown below (for the Events posts.php template) but it’s not sorting nor excluding older dates. The format of the post meta field _event_start_date is ‘2022-11-23’.

    query_posts(
    	bblgroups_get_posts_query_args(
    		array(
    			'post_type' => bblpro_get_current_post_type(),
    			 'order' => 'DESC',
            	'orderby' => 'meta_value',
    	        'meta_key' => '_event_start_date',
        	'meta_query' => array(
            array(
                'key' => '_event_start_date',
                'value' => date('Ymd'),
                'compare' => '>='
            	)
        	)
    	)
    	)
    );

    Any suggestions would be much appreciated.

    Regards
    Nik

  • Participant
    Level: Master
    Posts: 279
    NikB on in reply to: BuddyBlog Pro Posts Layout – 2 #47414

    Hi Brajesh

    Thank you so much. I had a feeling that might be the code I needed. I already tried using it previously but that was before removing the Events Manager scope so of course, nothing was working at that stage!

    What I’m actually hoping to do is filter out past events, which will require a query on the post meta but I’m used to working with WP_Query so that hopefully shouldn’t be a problem.

    I really do appreciate all your help and patience, and hopefully won’t need to trouble you on this particular aspect again 😉

    Regards
    Nik

  • Participant
    Level: Master
    Posts: 279
    NikB on in reply to: BuddyBlog Pro Posts Layout – 2 #47406

    Hi Brajesh

    Sorry I didn’t read that example carefully enough, which I now realise relates to single posts (and where they appear), whereas what I was hoping for was some way of filtering/restricting the list of posts which appear under “Posts” (ie. posts.php) on a profile eg. let’s say there is a category called “blog” which I want to exclude completely from the list.

    Note: I don’t need to change the permalink or make those posts show somewhere else but simply NOT show them in the list of posts on a (personal or group) profile.

    Hope that makes a bit more sense

    Regards
    Nik

  • Participant
    Level: Master
    Posts: 279
    NikB on in reply to: BuddyBlog Pro Posts Layout – 2 #47396

    Thank you so much Brajesh. That works perfectly.

    With regard to filtering out past dates, I completely understand this is outside of your scope but wonder if you could possibly just point me in the right direction with a simpler example eg. let’s say I wanted to only show posts from a particular category on a profile…

    I came across a snippet you’d posted here – https://buddydev.com/snippets/projects/buddyblog/ which seems to do just that but it uses the hook buddyblog_show_posts_on_profile which doesn’t seem to exist in BuddyBlog Pro or BuddyBlog Groups. Is there a similar hook I could use to add a filter to personal and group profiles?

    Or perhaps I should edit the relevant templates (eg. posts.php) and somehow filter that instead?

    Regards
    Nik

  • Participant
    Level: Master
    Posts: 279
    NikB on in reply to: BuddyBlog Pro Posts Layout – 2 #47394

    PS. I had a better look at your code and I can see that the reason it’s only working on group profiles is presumably because it’s using the bbl_groups_pre_container_contents hook. Is there a similar hook I can use for personal profiles?

    And could I also use the same hooks to add my own filter ie. to filter out past events?

    With many thanks again and will look forward to hearing from you.
    Nik