Support,
What is the best way to set og data so sites link Facebook do a proper pull?
Can I simply drop each og field in my template like this: <h4 class="posttitle" meta-property="og:title">[wpv-post-title]</h4>
or do i need to do further coding?
Thanks,
Charles
Dear Charles,
I assume we are talking about the "Open Graph protocol":
hidden link
If it is, according to above document, you will need to generate some meta codes using custom PHP codes, for example:
<meta property="og:title" content="The Rock" />
<meta property="og:type" content="video.movie" />
<meta property="og:url" content="<em><u>hidden link</u></em>" />
<meta property="og:image" content="<em><u>hidden link</u></em>" />
In a single post, you can use WordPress action hook "wp_head" to trigger a PHP function:
https://developer.wordpress.org/reference/hooks/wp_head/
Output the HTML codes as below:
1) og:title, you can use the post title, function get_the_title():
https://developer.wordpress.org/reference/functions/get_the_title/
2) og:type, you can setup a custom select field, render the value with Types function types_render_field()
https://toolset.com/documentation/customizing-sites-using-php/functions/
3) og:url, try the function get_permalink():
https://developer.wordpress.org/reference/functions/get_permalink/
4) og:image, try the function get_the_post_thumbnail_url():
https://developer.wordpress.org/reference/functions/get_the_post_thumbnail_url/
For your reference
Heading in the right direction.
How would I go about pulling the info from custom fields?
Like:
<meta property="og:title" content=[wpv-post-title] />
<meta property="og:type" content="article" />
<meta property="og:url" content=[types field='affiliate-url' output='raw'][/types] />
<meta property="og:image" content=[types field='product-image' output='raw'][/types] />
Thanks,
Charles
As I mentioned above, you can try Types API function types_render_field()
https://toolset.com/documentation/customizing-sites-using-php/functions/
Or wordpress built-in function get_post_meta():
https://codex.wordpress.org/Function_Reference/get_post_meta
Or use function do_shortcode() to render the shortcode, for example:
<meta property="og:url" content="<?php do_shortcode('[types field='affiliate-url' output='raw'][/types]'); ?>" />
https://developer.wordpress.org/reference/functions/do_shortcode/
So something like this:
<cpde>
<meta property="og:title" content="<?php do_shortcode('[wpv-post-title]'); ?>" />
<meta property="og:type" content="website" />
<meta property="og:url" content="<?php do_shortcode('[types field='affiliate-url' output='raw'][/types]'); ?>" />
<meta property="og:image" content="<?php do_shortcode('[types field='product-image' output='raw'][/types]'); ?>" />
<meta property="og:description" content="<?php do_shortcode('[types field='product-description' output='raw'][/types]'); ?>" />
[/php]
And I'm placing this where? Header, multiple places, or another?
Sorry, PHP is not my strong suit.
Thanks,
Chuck
Since it is a custom PHP codes problem, please provide a test site with the same problem, and fill below private message box with credentials and FTP access, also point out the problem page URL and where I can edit your PHP codes, I need a live website to test and debug