[Hummingbird] Cache and Custom Post Fetch Issue

Hi Everyone!

I hope you guys are doing well and I continue to love this site and its services. Looking forward to seeing any new and amazing products you bring to us.

I have a question and it’s been really bothering me. Not sure if it’s related to the caching in Hummingbird but I have a custom code that retrieves the latest custom post type from an author. A short code was created and placed inside a tab in BuddyPress. Basically, a simple code was created to add a custom post type to the WP dashboard and then a post is published by a specific user/author. That post is privately published, and the author was assigned to that post. Then the shortcode just pulls the latest post from that author from that specific post type.

Here’s the code used to create the custom post type:

* Register post type for User Content.
function buddydev_register_post_type() {
register_post_type( 'bp_user_content', array(
'label' => 'User Content',
'labels' => array( 'name' => 'User Contents' ),
'public' => false,
'show_ui' => true,
'supports' => array( 'title', 'editor', 'author', 'custom-fields' )
) );

/* New post type*/
register_post_type( 'post_type_name', array(
'label' => 'Label Post Type',
'labels' => array( 'name' => 'Plural Label' ),
'public' => false,
'show_ui' => true,
'supports' => array( 'title', 'editor', 'author', 'custom-fields' )
) );

add_action( 'init', 'buddydev_register_post_type' );

Here’s the code used to fetch latest post type and it is on GitHub:


The problem I am having:

I created a custom tab on buddypress called ‘Home’ with its own subnav called ‘Home’. In the content of that subnav, I have the following shortcode:

[bp-user-last-post post_type='custom post type name']

So, the ‘custom post type name’ will be replaced by any post type created. I am finding that most of the time the post ‘fetching’ works but other times it doesn’t. Sometimes when users are logged in, it works but when users are logged out, it doesn’t. This is why I am thinking maybe it is some caching problem.

Can someone take a look at the codes I provided and see if with your professional opinion, there may be something amiss or needs correcting?

Thank you!!