BuddyDev

Search

BuddyBlog Pro Posts Layout – 2

  • Participant
    Level: Master
    Posts: 279
    NikB on #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

  • Keymaster
    (BuddyDev Team)
    Posts: 24706
    Brajesh Singh on #47395

    Hi Nik,
    1. To apply it to user and group both, you may do the following

    Remove this

    
    add_action( 'bbl_groups_pre_container_contents', 'bblcustom_disable_em_scope' );
    

    and add this

    
    add_action( 'bblpro_actions', 'bblcustom_disable_em_scope' );
    

    Is there any way of screening out past events from the tabs? (Events Manager handles this for their own BuddyPress tabs but presumably we’re now removing that filter so is there a way of adding it back in?)

    I am sorry, I am unable to answer as I only took a peek at their code and havn’t invested much time. You will need assistance from Events Manager team.

    Regards
    Brajesh

  • Participant
    Level: Master
    Posts: 279
    NikB on #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

  • Keymaster
    (BuddyDev Team)
    Posts: 24706
    Brajesh Singh on #47405

    Hi Nik,
    Thank you.

    At the moment, we don’t have a filter to allow you filtering the permalink of a BuddyBlog specific post.
    I will add it in next release. We are dealing with multiple post types now, so It will be a bit different than the previous one. I will post after the update.

    Regards
    Brajesh

  • Participant
    Level: Master
    Posts: 279
    NikB on #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

  • Keymaster
    (BuddyDev Team)
    Posts: 24706
    Brajesh Singh on #47413

    Hi Nik,
    Thank you for clarifying.
    you can achieve it by overriding our loop template(posts.php)

    In that file you will find a code section like this

    
    query_posts(
    	bblgroups_get_posts_query_args(
    		array(
    			'post_type' => bblpro_get_current_post_type(),
    		)
    	)
    );
    

    In that array(where we have passed post type), you can pass any of the params supported by WP_Query

    https://developer.wordpress.org/reference/classes/wp_query/

    If you are using the ‘Category’, you can pass category__not_in. If you are using a custom taxonomy, you can pass the tax query.

    Regards
    Brajesh

  • Participant
    Level: Master
    Posts: 279
    NikB on #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 #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

  • Keymaster
    (BuddyDev Team)
    Posts: 24706
    Brajesh Singh on #47418

    Hi Nik,
    I don’t see any issue with your query except, It has incorrect assumption.

    You are trying to order by date while the ordering is happening by a string.
    Also, I am not sure if the value stored in ‘_event_start_date’ is comparable with your value(You will need to check that and verify).

    since you have been trying to get events manager working like this, my suggestion is to avoid forcing it to dom something they are not doing.
    You should use BuddyBlog for creating the entries while use their shortcode(events manager) for listing the entries.

    That will solve most of the issues you have faced.

    Regards
    Brajesh

  • Participant
    Level: Master
    Posts: 279
    NikB on #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

You must be logged in to reply to this topic.

This topic is: not resolved