• Resolved ludsonaiello

    (@ludsonaiello)


    I’m trying to load the DB fields before the page content. I would like to change my default template including some BD fields. Would I like to load the fields in various parts of my template but can not find any documentation that would allow me to call a function to display a specific field.

    I tried using the code below, but this function returns the shortcode [businessdirectory]. I need to customize the way content is displayed, need to change the title of the page, I need to know how to call the functions outside the template plugin.

    It’s possible?

    https://wordpress.org/plugins/business-directory-plugin/

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

    (@businessdirectoryplugin)

    Hi ludsonaiello,

    I’ll need to check with my developer about the details of loading. Some of what you want is contained in our customization guides:

    We have 3 options for customizing the look of the directory.

    1) First is custom CSS to do basic tweaks like fonts, spacing and colors. Here is an article about how to use custom CSS with Business Directory in a way that doesn’t get overwritten on upgrade of BD: http://businessdirectoryplugin.com/support-forum/faq/how-to-use-custom-styles-with-bd-2-1/

    2) For the more adventurous and layout-based changes, you can override templates: http://businessdirectoryplugin.com/support-forum/faq/customizing-bd-to-fit-your-theme/ And also do more with fields: http://businessdirectoryplugin.com/support-forum/faq/advanced-customization-of-the-list-and-detail-views-of-bd/

    3) But if that’s not enough, you can go full-bore and customize anything in the plugin if you have the proper skill set: http://businessdirectoryplugin.com/docs/customization-guide/

    Plugin Author Business Directory Plugin

    (@businessdirectoryplugin)

    Hi ludsonaiello,

    My developer responded:

    The customization guide (http://businessdirectoryplugin.com/support-forum/faq/advanced-customization-of-the-list-and-detail-views-of-bd/) is definitely the best place to go for info about displaying specific fields.

    That being said, trying to do that before the content could be problematic because BD might not know (yet) the listing that is going to be displayed. That’s the result of dispatching everything from a shortcode and one of the things addressed in our next major release.

    For now, a possible work-around might be something like the following:

    <?php
    // We need to create a function like this one.
    function current_listing() {
        global $wpbdp;
    
        if ( 'showlisting' != $wpbdp->controller->action )
            return 0;
    
        $id_or_slug = '';
        if ( get_query_var( 'listing' ) || isset( $_GET['listing'] ) )
            $id_or_slug = get_query_var( 'listing' ) ? get_query_var( 'listing' ) : wpbdp_getv( $_GET, 'listing', 0 );
        else
            $id_or_slug = get_query_var( 'id' ) ? get_query_var( 'id' ) : wpbdp_getv( $_GET, 'id', 0 );
        $listing_id = wpbdp_get_post_by_id_or_slug( $id_or_slug, 'id', 'id' );
    
        return $listing_id;
    }
    
    // Display or obtain the value from a specific field for the 'current' listing, as per
    // http://businessdirectoryplugin.com/support-forum/faq/advanced-customization-of-the-list-and-detail-views-of-bd/.
    
    $field = wpbdp_get_form_field( 4 );
    echo $field->display( current_listing() ); // This prints all HTML output for field with ID 4.
    echo $field->value( current_listing() ); // This prints just the value for the field with ID 4.
    ?>

    I hope that helps. Please let me know if you have any other questions or issues!

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Load fields before the_post content’ is closed to new replies.