• Resolved dinmix

    (@dinmix)


    Hi Guys,

    I know it’s not possible to create custom badges yet so I create a customs field instead. I created a field called Vouchers. Now all I need is to create a page to show all listings that accepted Vouchers.

    I can’t find information on how to do this. I saw there is a Key field on the documentation https://directorist.com/documentation/directorist/customization/custom-fields-on-add-listing-page/ and I supposed this could be used to pull out the listing with the same key. However, I didn’t see this Key field on the current Version 7.0.8.

    I can also achieve this if I can add Tag field in All Listing layout.

    Can you advise on this?
    Thank you

    • This topic was modified 2 years, 10 months ago by dinmix.
Viewing 5 replies - 1 through 5 (of 5 total)
  • Hi @dinmix, sorry for the delay in response.

    Our current documentation is currently a bit out of date, we’re working on making it compatible with the latest version of Directorist.
    Field Keys are no longer available for mutation by default. If you want to be able to see it or modify it, kindly copy-paste the below code on your theme’s functions.php and you should be good to go:

    
    add_filter('directorist_custom_field_meta_key_field_args', function ($args) {
        $args['type'] = 'text';
        return $args;
    });
    

    Regards,
    Mahdi.

    Thread Starter dinmix

    (@dinmix)

    Thank you Mahdi.

    This works perfectly. One last question, how can I display all the listings on a page using this key?

    Best Regards
    Din

    Hi @dinmix,

    Use this code on your theme’s functions.php,

    add_filter('atbdp_all_listings_query_arguments', 'atbdp_listing_query_arguments_custom');
    
    function atbdp_listing_query_arguments_custom($args)
    {
           if(is_page('page_id/page_slug')){ //page slug (as a string) or page id(as a integer)
             $args['meta_query']['key-field'] = array (
    		 	 'key' => '_key-field', //meta key for that field (must use underscore before the meta-key name)
    			 'value' => 'value', //value that you want to compare against
    			 'compare' => '=',
    		 );
           }
    	//e_var_dump( $args );
    	return $args;
    }

    Regards,
    Mahdi.

    Thread Starter dinmix

    (@dinmix)

    Thank you Mahdi

    I tried it but it doesn’t seem to show any listing. I have added the key-field and added the value based on the option value of the checkbox.

    Would you guys provide paid support?

    Hi @dinmix,

    We don’t really provide any Paid Support. But if you need help with anything custom, you can always get in touch with our technical support here: https://directorist.com/contact, we’ll help you as much as we can.

    Regards,
    Mahdi.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Custom Field Key & Insert Tag in All Listings’ is closed to new replies.