I use Jetpack’s Publicize module on my projects when clients want their posts to automatically show up on social media outlets like Twitter and Facebook. Sometimes a post needs to be re-Publicized because its link or title changed, but Jetpack only lets you Publicize it once. This can also be particularly limiting in a staging or testing environment, so I created this quick snippet that gives me a dashboard link to reset my post’s Publicize status which allows me to re-Publicize posts with Jetpack. Let’s break it down.
Create the Link
First we create the link in the WordPress dashboard using the post_submitbox_start
action hook and specify an action we will create in just a moment:
Create the Action
Jetpack added some metadata to your post, both before and after it’s published. So our action needs to remove the metadata associated with Jetpack to allow re-Publicizing it. So let’s get the post’s metadata and delete the data Jetpack created:
Notes
By default, Jetpack only Publicizes a post when you actually click publish, so you will need to unpublish the post you want to use this on, clear the Publicize metadata, and re-publish. It’s not the cleanest possible solution but it’s the quickest and it allows you to re-Publicize your posts with Jetpack to correct pesky errors or for testing purposes. Enjoy!
I love this post! I checkout your blog often and I shared this post on my
Facebook and my followers thought it was great. Keep up the awesome work.
Not sure if I need to include the leading <?php syntax, or if the code needs to be closed in some way?
Your PHP code changes were rolled back due to an error on line 104 of file wp-content/themes/storefront/functions.php. Please fix and try saving again.
syntax error, unexpected end of file
<?php
should only appear once at the start of yourfunctions.php
file, do not include it again. There’s no need for a closing?>
if the last line of the file is PHP. However, I don’t believe this works anymore because I think Jetpack tracks Publicize status on its own remote servers nowadays.Thanks for the clear explanation of PHP syntax – the question seemed so basic but I couldn’t find an answer elsewhere.
Also great to know that the patch won’t work now even in the right format!
Hi Michael. I love and have been using your solution for years now, but lately my posts aren’t being republished. I was wondering if you’ve noticed any changes that might cause your solution to stop working or if you might know what might be the issue? Cheers! Karl
Hi Michael thanks for your time to share this, but I really need help. I created the two files: clear_jetpack_published.php and clear_publicized_link.php, and put on the theme folder “theme functions” directory, but nothing happened… Please can you help me?
Thanks a ton. Works perfectly.
I was not even going to use Publicize till I found this.
Two frustrating to post find a mistake and you can’t fix it. It’s like having an undo button bet better.
WordPress should provide this.
Where is the link supposed to be ?
Hello Michael, how are you? Thank you for this post. Very useful to me, but, I have no ideia how to “First we create the link in the WordPress dashboard using the post_submitbox_start action hook”. I am not a code guy, but I know how to do some customization, but not this. I look some articles but, I am afraid to do a shit in my webiste. Can you help me with this example please? Thanks in advance and Merry Xmas!
Hi Eduardo, please check my comment above ^^
Thanks so much Michael! Works perfectly!
I’ve been looking for something like this. Where would I put these code files?
Hi David, the best place for this is your custom functions file, usually
functions.php
in your theme directory. Glad you find it useful!