Support » Plugin: Starbox - the Author Box for Humans » Show different post type on “Recent Posts” tab

  • Hi,

    Thank you for the awesome plugin – we are really loving it.

    It is giving us flexibility in showing up an author profile on the desired page. However, there’s a problem that we are having with our use case.

    We have a custom post type called “vlog” where we are showing up the author box.

    Check this for instance: https://ppc.university/vlog/how-to-use-discord-as-a-bookmarking-tool/

    The single-page shows the author box exactly the way we want, but the “Recent Posts” tab is showing the posts from WordPress’s default post type. As per our use-case, since we are showing up the author box on the “Vlog” post type, we were expecting it to list the posts from “Vlog” post type.

    I checked the code to see if we can customize the query arguments for “Recent Posts”, but there were no hooks available. I can’t see a way to change this – not from the code level, neither from the settings level. Or maybe I am looking at the wrong side.

    Can you help me out on this, please?

    Thanks in advance

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Contributor Calin Vingan

    (@calinvingan)

    Hi @abiralneupane,

    Thanks for your feedback.

    We added an update in Starbox with the option to hook the Latest Posts query.

    Here is an example you can add to the theme functions.php file:

    add_filter('abh_author_latest_posts', function($query){
     
    $args = array(  
            'post_type' => 'services',
            'post_status' => 'publish',
            'posts_per_page' => 5, 
            'orderby’ => 'title', 
            'order’ => 'ASC', 
        );
    
        return new WP_Query( $args );
    });

    Hope this helps.

    Calin

    • This reply was modified 1 month, 2 weeks ago by Calin Vingan.
    • This reply was modified 1 month, 2 weeks ago by Calin Vingan.
    Thread Starter Abiral Neupane

    (@abiralneupane)

    Hi Calin,

    Thank you for adding this to the plugin.

    One more thing, if you don’t mind, after you change the query using ‘abh_author_latest_posts’ there’s a code that fetches the category using ‘get_the_category()’. I believe this would only work if the post_type that WP_Query is querying is a ‘post’, For custom Taxonomy, I don’t beleive it would work.

    Is there any way, we can have a flexibility to do that?

    Also, we have updated the plugin into pro, but haven’t received any new update for this. Can you also update the pro version please?

    Thank you again for the support

    Best Regards
    Abiral Neupane

    Thread Starter Abiral Neupane

    (@abiralneupane)

    Hi there,

    Just following up on my last request.

    When can we expect a new release for the pro version, with the changes that we had on the free version?

    Thanks in advance

    Best Regards
    Abiral Neupane

    Plugin Contributor Calin Vingan

    (@calinvingan)

    Hi Abiral,

    We’ll release soon an update with these hook on the PRO version.

    I will let you know when it’s ready.

    Calin

    Thread Starter Abiral Neupane

    (@abiralneupane)

    Hi Calin, I just remembered one thing.

    The hook that you guys added “abh_author_latest_posts” gets triggered only after the query is run. The hook will replace the result of the query. So, if we need to override the query result, we need to run the query twice.

    So, I think it will be better if there was a hook to modify the query arguments in the first place like this

    $latest_posts = new WP_Query(
        apply_filters('abh_author_latest_posts_args', array(
            'posts_per_page' => ABH_Classes_Tools::getOption('anh_crt_posts'), 
            'author' => $this->author->ID
        ));
    );
    
    $latest_posts = apply_filters('abh_author_latest_posts', $latest_posts);

    If some other themes or plugin uses this new hook, it will not affect the performance like it does if the ‘abh_author_latest_posts’ hook is used.

    I hope you would consider this.

    Thank you again for your kind co-operation.

    Best
    Abiral Neupane

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.