field for meta data
This topic contains 19 replies, has 4 voices, and was last updated by Joy 7 years, 3 months ago.
We have moved to a support ticketing system and our forums are now closed.
Open Support Ticket-
AuthorPosts
-
July 18, 2018 at 5:22 pm #438951
I have a custom field in my listings that I want to add to SEO Metadata
July 18, 2018 at 6:03 pm #438966Here is an example for titles: https://wpgeodirectory.com/support/topic/meta-title-tages/#post-369400
Let us know how it goes
July 19, 2018 at 11:01 am #439031Hi 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.
July 19, 2018 at 11:38 am #439034The 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
July 19, 2018 at 11:47 am #439037Hi 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.
July 19, 2018 at 11:55 am #439041Its 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
July 20, 2018 at 11:04 am #439174Great, thank you Stiofan. I hope you’ve been well. 🙂
July 20, 2018 at 11:29 am #439175Has 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.
July 20, 2018 at 2:27 pm #439196try 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
July 22, 2018 at 12:09 am #439277Thank 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?
July 23, 2018 at 1:07 pm #439416Please provide wp-admin and i’ll take a look.
Stiofan
July 23, 2018 at 1:19 pm #439418This reply has been marked as private.July 23, 2018 at 1:55 pm #439425It would help if i knew the website and username also 🙂
Stiofan
July 23, 2018 at 2:01 pm #439426This reply has been marked as private.July 23, 2018 at 4:17 pm #439440This 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
-
AuthorPosts
We have moved to a support ticketing system and our forums are now closed.
Open Support Ticket