Pay with a like shows suspect description

Hello, I have installed the plugin and tested sharing. The problem is that I have set the like to be the main domain name, but when I use twitter, it adds the link to the main domain, but the description it provides is the post that is used to display the details of the offer. I would like it to show the description (or to be more specific) the title of the page that is being liked. Is this possible? It seems odd that I can change the link but not the title as this will result in page A being liked while the description for page B is shown.

  • Kimberly

    Hey there!

    Currently I don't see any way to specify the info you are looking to provide.

    All social media use different ways to gather the info they share from an external website.

    Looking at the code it does seem that there is a way to get twitter to pull specific text, however that would require some coding adjustment.

    I will mark this one as a feature request and see if we can get the developer to comment here on what our options are :slight_smile:

    Best,

    Kimberly

    Hakan- is it possible to add a data-text element to Twitter? It currently shares the content of the "Description above the buttons" field which is not very desirable.

  • Hakan

    Hi,

    Currently it doesn't share the "Description" field. It shares whatever inside <title> tag which should be desirable.

    However, if you want to share "post title", this is also possible. Include this snippet inside functions.php of your theme:

    add_filter( "pwal_render_button_html", "add_post_title_to_twitter", 10, 2 );
    function add_post_title_to_twitter ( $content, $post_id ) {
    	if ( !$post_id )
    		return $content;
    	$post = get_post( $post_id );
    	return str_replace( "class='twitter-share-button'", "class='twitter-share-button' data-text='". $post->post_title ."'", $content );
    }

    Cheers,
    Hakan

  • BusinessOnlinePh

    Hello, sorry, I think I totally described that incorrectly.

    Here is what happens. If I add it to a post which is located at domain.com/category/test-post and the title of the post is "This is a test, share to win". Within the plugin I set the address to share as "domain.com", it will share the link domain.com but the title it uses is the title of where the post containing the pay with a tweet shortcode.

    So it would look like this:
    This is a test, share to win - Domain.com

    What it is doing is sharing the title of the post where the pay with a tweet shortcode is located and not the item set within the plugin to be the address to share.

    It seems to work when set to share a random post or the same post, but if I set a static location to share, that is when it shares the wrong title.

  • Hakan

    Hi,

    I see what you mean. You are filling the "URL to be liked" field. Then the solution is similar to that mentioned above. Instead of "$post->post_title", just add the text you wish:

    add_filter( "pwal_render_button_html", "add_post_title_to_twitter", 10, 2 );
    function add_post_title_to_twitter ( $content, $post_id ) {
            $custom_title = "Whatever";
    	return str_replace( "class='twitter-share-button'", "class='twitter-share-button' data-text='". $custom_title ."'", $content );
    }

    Cheers,
    Hakan

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.