• Resolved chrisk2020

    (@chrisk2020)


    Hi – Great plugin,
    I need to add some alternate urls to a post so that I can aggregate social metrics – the page is essentially an archive of a custom post type – but I’d like the metrics of the page to reflect all the (12) sub-posts. The sub posts 301 to the parent with an exception for the facebook crawler.

    I’m using Advanced Custom Fields plugin for …custom fields and wondered if you could give me any information on how to set up a custom field as a serialised array in such a way to set this up?

    So far I’ve tried using the ‘relationship’ field, but this stores post IDs in the array so I’m not sure that would work?

    Appreciate any pointers.

    https://wordpress.org/plugins/social-metrics-tracker/

Viewing 1 replies (of 1 total)
  • Plugin Author Ben Cole

    (@bcole808)

    Hello!

    If I understand correctly, it sounds like you have a Page with some sub-posts and you want this plugin to fetch data for all the URLs to all of the sub-posts but add the numbers all to the parent Page and pretend that the shares came from that Page.

    If so… you will have to add some custom meta fields to the parent Page which you want to receive the metrics. For each additional URL, you need to add another entry. Here’s an example of how to do this with PHP code:

    $post_id = 10; // The ID of the parent Page we want to attribute the numbers to
    
    add_post_meta($post_id, 'socialcount_url_data', 'http://www.example.com/alt-url-1');
    add_post_meta($post_id, 'socialcount_url_data', 'http://www.example.com/alt-url-2');
    add_post_meta($post_id, 'socialcount_url_data', 'http://www.example.com/alt-url-3');
    
    // Important: Make sure this code only runs once so as not to keep adding endless URLs to track.

    If you were to run the code above, the plugin would then fetch data for all three alt-urls and attribute the scores to the page with $post_id.

    However, you don’t have to do this with code and you don’t need any plugins either. On an individual post or page, there is a section built into wordpress called “Custom Fields” which you can use to set these values.

    More info can be found in the readme here: https://github.com/chapmanu/wp-social-metrics-tracker#setting-alternate-urls

    Hope this helps!

Viewing 1 replies (of 1 total)
  • The topic ‘Alternative Urls config with ACF plugin’ is closed to new replies.