field for meta data

This topic contains 19 replies, has 4 voices, and was last updated by  Joy 5 years, 9 months ago.

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

Open Support Ticket
  • Author
    Posts
  • #438951

    Doug Rooney
    Expired Member
    Post count: 22

    I have a custom field in my listings that I want to add to SEO Metadata

    #438966

    Alex Rollin
    Moderator
    Post count: 27815

    Here is an example for titles: https://wpgeodirectory.com/support/topic/meta-title-tages/#post-369400

    Let us know how it goes

    #439031

    Joy
    Buyer
    Post count: 1076

    Hi Alex, I am assisting Doug with this matter. From what I can see, it doesn’t seem that a custom field can be hooked into the meta data. Can you please check with the devs if there is a workaround for this? Thank you.

    #439034

    Alex Rollin
    Moderator
    Post count: 27815

    The example is here, the snippet would need to be customized with the appropriate field, right now it is using post zip:

    https://wpgeodirectory.com/support/topic/meta-title-tages/#post-369400

    #439037

    Joy
    Buyer
    Post count: 1076

    Hi Alex, the zip code is part of the native data so I see how that data is being hooked in with the meta data. However, we are trying to integrate a custom field that we created within a custom post type listing into the meta data. That goal doesn’t seem to be the same situation as the post you’ve linked.

    #439041

    Stiofan O’Connor
    Site Admin
    Post count: 22956

    Its pretty much the same, though the custom fields are prefixed with “geodir_” so if ur custom field htmlvar is “price” its key would be “geodir_price”

    Stiofan

    #439174

    Joy
    Buyer
    Post count: 1076

    Great, thank you Stiofan. I hope you’ve been well. 🙂

    #439175

    Joy
    Buyer
    Post count: 1076

    Has there been any changes that would prevent the snippet from working? I’ve added this in:

    
    
    add_filter( 'geodir_wpseo_replacements_vars', '_my_extra_seo_vars',10,2);
    
    function _my_extra_seo_vars( $vars, $location_array ){
      global $post;
      
      $vars['%%geodir_metro%%'] = isset($post->geodir_metro) ? $post->geodir_metro : '';
      
       return $vars;
    }

    Then in my Yoast meta I’ve added: %%title%% %%in_location%% %%geodir_metro%%

    The meta description is not affected. Only the title and location is appearing.

    #439196

    Stiofan O’Connor
    Site Admin
    Post count: 22956

    try changing it to

    $vars['%%geodir_metro%%'] = '123'

    to see if it makes any difference, it might be that its not defined there and u might have to use geodir_get_post_meta();

    Stiofan

    #439277

    Joy
    Buyer
    Post count: 1076

    Thank you for trying to help. Neither of these options seem to work. I’ve tried the following code:

    $vars['%%geodir_metro%%'] = geodir_get_post_meta($post->geodir_metro, 'geodir_metro', true);
    $vars['%%geodir_metro%%'] = '123'

    Any other ideas on getting this to work?

    #439416

    Stiofan O’Connor
    Site Admin
    Post count: 22956

    Please provide wp-admin and i’ll take a look.

    Stiofan

    #439418

    Doug Rooney
    Expired Member
    Post count: 22
    This reply has been marked as private.
    #439425

    Stiofan O’Connor
    Site Admin
    Post count: 22956

    It would help if i knew the website and username also 🙂

    Stiofan

    #439426

    Doug Rooney
    Expired Member
    Post count: 22
    This reply has been marked as private.
    #439440

    Stiofan O’Connor
    Site Admin
    Post count: 22956

    This works (i have applied it)

    
    
    add_filter( 'geodir_wpseo_replacements_vars', '_my_extra_seo_vars',10,2);
    function _my_extra_seo_vars( $vars, $location_array ){
      global $post;
        $geodir_metro = isset($post->geodir_metro) ? $post->geodir_metro : '';
        if(!$geodir_metro){$geodir_metro = geodir_get_post_meta($post->ID,'geodir_metro',true);}
        $vars['%%geodir_metro%%'] = $geodir_metro;
       return $vars;
    }

    Stiofan

Viewing 15 posts - 1 through 15 (of 20 total)

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

Open Support Ticket