• Resolved jcarrier

    (@jcarrier)


    Support –

    Can you let me know how to add Category Hashtags prefixed to Jetpack Publicize tweets? Certainly, the awesome team at Automattic can make that happen.

    I have Twitter Cards working through WordPress SEO but want to add a Category Hashtag prefix as a template to outgoing Jetpack Publicize tweets.

    Thanks for an outstanding plugin!

    jcarrier

    https://www.ads-software.com/plugins/jetpack/

Viewing 15 replies - 1 through 15 (of 30 total)
  • Plugin Author Jeremy Herve

    (@jeherve)

    Jetpack Mechanic ??

    It’s not possible yet, unless you do it manually for each post thanks to the Publicize options appearing above the Publish button.

    We’re thinking about adding such feature though; you can follow our progress in this trac ticket:
    https://plugins.trac.www.ads-software.com/ticket/1785

    Thanks for your feedback!

    Thread Starter jcarrier

    (@jcarrier)

    Jeremy –

    Thanks for the reply.

    In the interim, I am conversant with PHP coding so perhaps you could give me some insight as to how I could tweak the publicize.php file to prefix twitter published posts to auto include a category hashtag.

    This would really help me out a great deal.

    Thanks in advance for your assistance.

    jcarrier

    Thread Starter jcarrier

    (@jcarrier)

    Jeremy –

    I am having serious trouble with Jetpack publicize to Facebook. I have determined this is not a Facebook issue after debugging the scraped URL using:

    https://developers.facebook.com/tools/debug/og/object?q=http%3A%2F%2Fwww.worldnewsreader.com%2Fhealth%2Fhow-to-make-the-best-back-stretch-even-better (results in response code 200)

    Also, I have tried to simultaneously publish using both Jetpack publicize and the Next Scripts plugin. You can see that there is no issue when Next Scripts plugin submits the post to Facebook. As of today, when Jetpack publicize submitted the post, it only shows the title and the shortened URL even though all of the open graph tags are found as provided by WordPress SEO (doesn’t work either if it uses just Jetpack open graph tags by deactivating WordPress SEO).

    https://www.facebook.com/pages/World-News-Reader/161526423996456

    I have deactivated/reactivated all plugins, deactivated/reactivated Jetpack itself and disconnected/reconnected the Facebook app connection several times as instructed. Nothing seems to work.

    You can see that Jetpack publicize worked perfectly yesterday.

    Please advise how to resolve this issue.

    Thanks in advance for expediting.

    jcarrier

    Thread Starter jcarrier

    (@jcarrier)

    Jeremy –

    I spent hours on this issue this morning after taking a mental break.

    I finally figured it out. You have to complete disconnect both Facebook AND Twitter as Publicize connections, then connect Facebook FIRST otherwise Facebook publicize posts never works right. Automattic should emphasize that in the documentation.

    It’d be great if you could lend insight on how I can tweak the publicize.php to include category hashtags for Jetpack publicize tweets.

    Thanks again.

    jcarrier

    Thread Starter jcarrier

    (@jcarrier)

    BTW – funny enough – now all my Jetpack publicize posts to both Facebook and Twitter include bit.ly links. Before bit.ly links were only included in Jetpack publicize tweets.

    Is this a new change to include the shortened URL with Jetpack Publicize or Facebook policy or did Facebook just have to pick up that I had the shortened URL available?

    Very curious…

    Plugin Author Jeremy Herve

    (@jeherve)

    Jetpack Mechanic ??

    I am conversant with PHP coding so perhaps you could give me some insight as to how I could tweak the publicize.php file to prefix twitter published posts to auto include a category hashtag.

    The Publicize default messages are built in this file:
    https://plugins.trac.www.ads-software.com/browser/jetpack/tags/2.5/modules/publicize/publicize.php

    I have determined this is not a Facebook issue after debugging the scraped URL using:

    https://developers.facebook.com/tools/debug/og/object?q=http%3A%2F%2Fwww.worldnewsreader.com%2Fhealth%2Fhow-to-make-the-best-back-stretch-even-better

    I actually receive a 404 for that link:
    https://i.wpne.ws/SCtf

    Did you unpublish that post?

    now all my Jetpack publicize posts to both Facebook and Twitter include bit.ly links. Before bit.ly links were only included in Jetpack publicize tweets.

    Jetpack doesn’t handle custom shortlinks like bit.ly. But if you use another plugin to create these shortlinks, it’s possible that the plugin was updated to become compatible with Jetpack Publicize.

    Thread Starter jcarrier

    (@jcarrier)

    Jeremy –

    Yes; I got it to work so I trashed the test posts associated with the issue.

    Regarding, adding category hashtags, I suspect that I simply have to change:

    var $default_prefix = ”;
    var $default_message = ‘%title%’;
    var $default_suffix = ‘ %url%’;

    To the following:

    var $default_prefix = ‘#%category%’;
    var $default_message = ‘%title%’;
    var $default_suffix = ‘ %url%’;

    For some reason, it doesn’t seem to work. Can you advise how to fix it within the publicize.php file? Thanks again.

    jcarrier

    Plugin Author Jeremy Herve

    (@jeherve)

    Jetpack Mechanic ??

    Instead of editing these values, you can use the filters we added for each value: wpas_default_message, wpas_default_prefix, ‘wpas_default_suffix’.

    You can find more info about this here:
    https://vip.wordpress.com/documentation/customizing-publicize-sharing-behavior/

    Thread Starter jcarrier

    (@jcarrier)

    Jeremy –

    Thanks for the reply.

    I see that the following is the filter that I should revise:

    $this->default_prefix = Publicize_Util::build_sprintf( array(
    apply_filters( ‘wpas_default_prefix’, $this->default_prefix ),
    ‘url’,

    Please advise exactly how I should revise it so that Jetpack publicize would publish as:

    #Category Title URL

    Thanks again for your help.

    jcarrier

    Plugin Author Jeremy Herve

    (@jeherve)

    Jetpack Mechanic ??

    You could use get_the_terms( $post_id, 'category' ); to get the category, and then hook this category into the wpas_default_prefix filter with add_filter(#).

    I hope this helps.

    Thread Starter jcarrier

    (@jcarrier)

    Jeremy –

    Thanks for your patience with solving this issue. I confess I am not a guru programmer like yourself. Can you simply provide a rewritten code snippet to insert into the current publicize.php script?

    I sort of get how this may work in implementation but can’t quite put it together right.

    Thanks again.

    jcarrier

    Plugin Author Jeremy Herve

    (@jeherve)

    Jetpack Mechanic ??

    Try saving this code to a functionality plugin:

    // Create our custom Publicize message
    function jeherve_cust_pub_message() {
    	$post = get_post();
    
    	// Grab the first category of your post
    	if ( !empty( $post ) )
    		$categories = get_the_category( $post->ID );
    
    	if ( !empty( $categories ) ) {
    		$previous_cust = get_post_meta( $post->ID, '_wpas_mess', true );
    
    		$custom_message = $categories[0]->cat_name . ' ' . $previous_cust;
    
    		update_post_meta( $post->ID, '_wpas_mess', $custom_message );
    	}
    }
    
    // Save that message
    function jeherve_cust_pub_message_save() {
    	add_action( 'save_post', 'jeherve_cust_pub_message', 21 );
    }
    add_action( 'publish_post', 'jeherve_cust_pub_message_save' );
    Thread Starter jcarrier

    (@jcarrier)

    Jeremy –

    Thanks for the reply. Here is what I have attempted thus far:

    I activated the https://www.ads-software.com/plugins/functionality/ plugin and added the code snippet to the plugin/functions.php file. Unfortunately, I couldn’t figure out how to activate the functions.php file with the new code. It just kept stating ‘inactive’.

    Next, I tried another plugin by the same author https://www.ads-software.com/plugins/code-snippets but the category hashtags did not show in the publicized posts for either Facebook, Twitter or Tumblr after inserting the code snippet.

    Lastly, I tried to create a custom plugin and upload the zipped file to my WP install. This worked fine based on the custom code snippet provided but failed on activation.
    Here is the error code that I received upon attempting activation:

    Parse error: syntax error, unexpected ‘&’ …

    The error in the code snippet corresponds to the following:

    $categories = get_the_category( $post->ID );

    I am running a LAMP install (PHP 5.3) of a 3.6.1 WP website. Please advise how best to resolve the code snippet issue so I can get this up and running.

    Thanks again.

    jcarrier

    Plugin Author Jeremy Herve

    (@jeherve)

    Jetpack Mechanic ??

    Parse error: syntax error, unexpected ‘&’ …

    The error in the code snippet corresponds to the following:

    $categories = get_the_category( $post->ID );

    Could you compare the code in your plugin and the code I pasted above? As you can see, my code doesn’t include the “&” symbol. Your plugin probably includes that symbol somewhere.

    Thread Starter jcarrier

    (@jcarrier)

    Jeremy –

    I realized that the email notification I received had some URL encoding issues.

    Therefore, I copied/pasted the original code snippet that you provided in the WP forum. I inserted that as a code snippet using https://www.ads-software.com/plugins/code-snippets but that did not add the Category Hashtags to publicized posts.

    Also, I tried to copy/paste the original code snippet into a custom plugin. That activated without issue but once again it did not add Category Hashtags to publicized posts.

    Is there something else that I need to do at this point for Category Hashtags to be added to publicized posts? Please let me know.

    Thanks again.

    jcarrier

Viewing 15 replies - 1 through 15 (of 30 total)
  • The topic ‘WordPress SEO – Twitter – Hashtag Support’ is closed to new replies.