Field in wordpress listing dashboard but not in add listing

Home Forums WordPress Theme CityBook – Directory & Listing WordPress Theme Field in wordpress listing dashboard but not in add listing

This topic contains 7 replies, has 2 voices, and was last updated by  CTHthemes 1 week, 1 day ago.

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #38096

    cravenplan99
    Participant

    Supported

    Hi there,

    Is it possible to have a field just in the wordpress backend Citybook listings edit page that is not present on the Add/Edit listings website users page?

    #38126

    CTHthemes
    Keymaster

    The theme use CMB2 plugin for custom metabox, so you can use it to add field on listing editing screen: https://github.com/CMB2/CMB2/wiki/Basic-Usage
    Example code can be found here: https://prnt.sc/ptipvm

    #38139

    cravenplan99
    Participant

    Supported

    Thank you for this. I can now see there is a way to do it but after looking at this all morning its a little over my head, unfortunately (one of the reasons I am using your theme). Is there an easy way to add a metabox to the edit listing page? Or could you give me some pointers please (it would be very much appreciated).

    #38153

    CTHthemes
    Keymaster

    This is customization question, so you have to do it by yourself or order an customization service.
    But here is an example for showing New Option field, add it to child-theme functions.php file:

    
    add_action( 'cmb2_admin_init', 'new_cmb2_sample_metaboxes' );
    /**
     * Define the metabox and field configurations.
     */
    function new_cmb2_sample_metaboxes() {
    
        // Start with an underscore to hide fields from custom fields list
        $prefix = '_cth_';
    
        /**
         * Initiate Post metabox
         */
        $listing_cmb = new_cmb2_box( array(
            'id'            => 'listing_options',
            'title'         => esc_html__( 'Custom Options', 'citybook-add-ons' ),
            'object_types'  => array( 'listing'), // Post type
            'context'       => 'normal',// normal, side and advanced
            'priority'      => 'high',// default, high and low - core
            'show_names'    => true, // Show field names on the left
        ) );
    
        $listing_cmb->add_field( array(
            'name' => esc_html__('New Option', 'citybook-add-ons' ),
            'id'   => $prefix . 'option_name',
            'type' => 'textarea_small'
        ) );
    
    }
    #38205

    cravenplan99
    Participant

    Supported

    Thank you so so much for this. I can now see my field in the backend but cannot get it to appear in my listing. I have added a Custom Field in the Single area of Listing Types and entered the ID but it is not showing. Any ideas please?

    #38217

    CTHthemes
    Keymaster

    Enter your field name here: https://prnt.sc/pvs7c6 ( without _cth_ prefix )

    #38226

    cravenplan99
    Participant

    Supported

    Fabulous! Thank you so much.

    #38238

    CTHthemes
    Keymaster

    You are most welcome 🙂

Viewing 8 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic.

New featues: CityBook - Listing & Directory WordPress Theme version 2.1.8 was outUpdate now
+