How would I add the capability in Simple Twitter Connect (in the stc-publish.php file) to not tweet pages, either newly published or edited? I don't need it to be an admin option, just a change for a few of my sites.

It looks like this function would be a good place to add the "don't tweet pages" capabilty (while retaining the check to prevent edited posts from being tweeted) as it checks for edited posts. How can one differentiate between posts and pages?

// this new function prevents edits to existing posts from auto-posting
function stc_publish_auto_check($new, $old, $post) {
    if ($new == 'publish' && $old != 'publish') {
        $post_types = get_post_types( array('public' => true), 'objects' );
        foreach ( $post_types as $post_type ) {
            if ( $post->post_type == $post_type->name ) {
                stc_publish_automatic($post->ID, $post);

Edit 4/03/11

Answer and better edit below.

  • @Otto should chime in on this one.
    – Chris_O
    Apr 1 '11 at 19:00
  • That would be great! I know there's gotta be a better way to do this (that doesn't involve editing the plugin), it's just a bit over my head! Apr 4 '11 at 11:09
  • @Otto did; see below. Jun 2 '11 at 21:07

Even better answer that doesn't involve changing the plugin:

function my_custom_publish_rules($new, $old, $post) {
  if ($post->post_type == 'page') return;
  else stc_publish_auto_check($new, $old, $post);

Put it in a theme's functions.php.

Side note: Whenever you're dealing with a function called by an action or filter hook, then you can easily wrap the call in a different function and add your own code to that function instead. remove_action and remove_filter should be two tools you use a lot in your WP arsenal.

  • Ah hah, that is. I'll use it instead of changing your plugin. Thanks! Jun 2 '11 at 21:06

General Disclaimer: This is a plugin edit. Any edits to plugins will be lost when the plugin is updated. Therefore this is not recommended unless you keep good notes and/or remember you did this when the plugin gets updated!! ;) (@songdogtech, I know you are aware of such things, but I thought it would be irresponsible to post this without that)


is how I block a CPT in the SFC plugin, the STC plugin works the same

look for the stc_publish_automatic function I believe it is and add post type page to it...

I'll find the code real quick, but wanted to point it out.... yer in the right file, and close to the right code


function stc_publish_automatic($id, $post) {

    // check to make sure post is published
    if ($post->post_status !== 'publish') return;

I'd think editing this bit to:

    function stc_publish_automatic($id, $post) {

        // check to make sure post is published
        if ($post->post_status !== 'publish') return;
     if ($post->post_type == 'page') return;

would do it.... (untested, but if worked for blocking a CPT in the SFC plugin)

If you look at the post I linked, @Otto made some recommendation in the comment you may be able to work with in a better way. I just edit the plugin as a quick and dirty, but looks like you can work it from your theme too.....

If anyone can take the info here, and the info from @Otto's comment on my site, and work it out, I'd love to see that code!

  • Thanks! Adding that one line works great to prevent new pages from being tweeeted. I'm obviously just learning php.... Apr 3 '11 at 17:36
  • I'm glad it worked for you! I'm just learning myself, so the above is what I figured out that works. Apr 4 '11 at 11:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.