Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Business Directory Plugin

    (@businessdirectoryplugin)

    Hi qtpankasingh,

    I’m not sure–this is something I’d have to ask my developer. It may be a few days before I hear back because he’s got a few support requests ahead of you in the list.

    I’ll report back when I know more.

    Thread Starter qtpankajsingh

    (@qtpankajsingh)

    Ok! I’ll be waiting for your answer

    Plugin Author Business Directory Plugin

    (@businessdirectoryplugin)

    OK, I got an answer for you:

    The latest featured post inside a category can be obtained with some code similar to this one:

    <?php
    $category_slug = 'my-category';
    $latest_featured = get_posts( array( 'post_type' => WPBDP_POST_TYPE,
                                         'post_status' => 'publish',
                                         'numberposts' => 1,
                                         'orderby' => 'date',
                                         'order' => 'DESC',
                                         'tax_query' => array(
                                            array( 'taxonomy' => WPBDP_CATEGORY_TAX,
                                                   'field' => 'slug',
                                                   'include_children' => true,
                                                   'terms' => $category_slug )
                                         ),
                                         'meta_query' => array( array( 'key' => '_wpbdp[sticky]', 'value' => 'sticky' ) )
    ) );
    
    if ( $latest_featured )
        $post = $latest_featured[0];
    else
        $post = null;
    
    if ( ! $post )
        echo 'There are no featured posts in the category.';
    
    // Title, description (excerpt) or content are as in a regular post:
    // $post->post_title, $post->post_excerpt, $post->post_content
    
    echo '<h3>' . $post->post_title . '</h3>';
    
    // Thumbnail is obtained using wpbdp_listing_thumbnail();
    echo wpbdp_listing_thumbnail( $post->ID );
    
    // Other fields should be accessed via the Form Fields API as explained at
    // https://businessdirectoryplugin.com/support-forum/faq/advanced-customization-of-the-list-and-detail-views-of-bd/
    ?>

    Here, $category_slug is the slug for the category. The post title, excerpt and content are available in the $post variable because listings are just regular posts, but details from “meta” form fields have to be queried using the Form Fields API as explained at https://businessdirectoryplugin.com/support-forum/faq/advanced-customization-of-the-list-and-detail-views-of-bd/.

    Installing and debugging this into your theme/templates will need to be done on your own–we can provide general guidance, but any issues arising will need to be worked out by you.

    Thread Starter qtpankajsingh

    (@qtpankajsingh)

    Ohh Thank you so much replying.
    It has sort my problem.
    I just need to know one more thing.
    Can I get attached image with this listing in the size I wish to ?
    If I use wpbdp_listing_thumbnail(), it gives image of size 150×80.
    But I need a bigger image size.

    Thanks in advance !

    Plugin Author Business Directory Plugin

    (@businessdirectoryplugin)

    The thumbnail API all will return the image that you configured for size under Directory Admin->Manage Options, Images tab. The easy fix to do is increase the size of the thumbnail if you want something a little bigger.

    If you want the full size image, try using the “advanced API” article here, where we talk about things like that. It should work in the same loop: https://businessdirectoryplugin.com/support-forum/faq/advanced-customization-of-the-list-and-detail-views-of-bd/

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘How to get latest featured listing for a specific category’ is closed to new replies.