• Resolved samrot

    (@samrot)


    Hi!

    I’m copying my question from another topic and the reply here in case it helps someone else and so we can continue it here.

    My question was:

    We have a custom post type of rentals in our website that users can create from a frontend form. For the rental description we have created a custom field.
    How can we assign this custom field as the meta description of each rental so the plugin automatically takes the meta description from that custom field on each new rental created?
    Right now the meta description of each rental is empty by default.
    Looking forward for your comments.
    Best!

    The reply was:

    you’re looking for this filter: the_seo_framework_description_excerpt.
    Here’s an example to get started: https://tsf.fyi/kb/a/160#set-custom-post-type-archive-descriptions.

    If you need help with that, please ask about it in a new topic. I think it’d be helpful to know how you created the custom field. Thank you!

    Continuation…

    To be more specific, I’m using the plugin Easy Property Listings that creates a custom post type called ‘rental’ and created the custom field with this code for the back-end:

    function my_epl_add_desc_field($group) {
    $group['fields'][] = array(
    'name' => 'property_description',
    'label' => __('Property description', 'epl'),
    'type' => 'textarea',
    'maxlength' => '2400'
    );
    return $group;
    }
    add_filter('epl_meta_groups_property_heading', 'my_epl_add_desc_field');

    And to display it on the front-end:

    function my_property_custom_data() {
    global $property;
    // Get the custom variable
    $custom_data = $property->get_property_meta( 'property_description' );
    if ( isset ($custom_data) ) {
    // Echo the custom variable if there is a value. You can wrap in a span tag.
    echo '<span class="property-description">' . $custom_data . '</span>';
    }
    }
    // This will echo the custom variable above the content
    add_action( 'epl_property_the_content' , 'my_property_custom_data' , 20 );

    So again, the question…

    How can we assign this custom field as the meta description of each rental so the plugin automatically takes the meta description from that custom field on each new rental created?

    Hope I made myself clear.

    Looking forward to your comments.

    Best!

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.