‘geodir_get_post_meta’ for file upload custom input

This topic contains 6 replies, has 3 voices, and was last updated by  Alex Rollin 6 years, 11 months ago.

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
  • Author
    Posts
  • #448992

    noa a
    Free User
    Post count: 2

    Hello,
    I added a custom file upload input and I would like the uploaded image to be the post’s featured image. What is the best way to code this?
    I found a relevant file: widget-listing-listview.php and I also saw that the basic code is:

    
    
    $contact= geodir_get_post_meta($post,’geodir_contact’,true);
    echo $contact;

    However I need to set the functionality of the custom file upload output so it would take the first image and set it as the post’s featured image. Basically it needs the same functionality that the built-in photos input has.
    Thank you!

    #449008

    Alex Rollin
    Moderator
    Post count: 27815

    Hello,

    this functionality is built in to GDV2 with the Logo field. If a file is uploaded to it, it will show in the listings view as the first image.

    For GDV1, this is a customization and requires editing several core files which is not recommended as the updates will be overwritten.

    The procedure to customize templates is outlined here: https://wpgeodirectory.com/docs/customizing-geodirectory-templates/

    I will flag your question for the developers to see what additional guidance they can provide.

    To try GDV2 see: https://wpgeodirectory.com/try-geodirectory-v2/

    At least this will require editing

    listing-detail.php
    listing-listview.php

    #449014

    Kiran
    Moderator
    Post count: 7069

    Hello There,

    Use following code snippet (replace geodir_myfile with your field name).

    echo geodir_cf_file( '', '', 'geodir_myfile', $post );

    Kiran

    #449022

    noa a
    Free User
    Post count: 2

    Thank you Kiran, unfortunately the code doesn’t work..
    Regarding your reply, Alex, thank you. For now I would just like to know how to display any output of a custom file upload input (with the HTML variable and the geodir_get_post_meta function).

    #449029

    Kiran
    Moderator
    Post count: 7069

    Hello,

    Snippet i have provided is used to output particular field. I have tested on my test site and it worked fine.
    For detailed code check this: https://github.com/GeoDirectory/geodirectory/blob/master/geodirectory-functions/custom_fields_output_functions.php#L1221

    Kiran

    #449054

    noa a
    Free User
    Post count: 2
    This reply has been marked as private.
    #449083

    Alex Rollin
    Moderator
    Post count: 27815

    You need to use the geodir_ prefix.

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

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
20% Discount Offer
Hurry! Get your 20% discount before it expires. Get 20% Discount