When you create a post of any type (either post or page or custom taxonomy) it gets a permalink that visitors can click on and visit.

 http://example.com/my_first_blog_post_permalink/

However, if you Publish the post, BUT make the publish date in the future, the post is shown as 'Scheduled' in the Admin and the permalink shows like so:

 http://example.com/?p=2848

And then also, when I try to share the post on Facebook, it does not share properly (ie. the preview text and image do not appear).

I include the FB include code just for completeness. But what I really want to know is--how do I get a 'scheduled' post behave like a 'published' post when it comes to the purposes of the permalink.

 function add_opengraph_doctype( $output ) {
    return $output . ' xmlns:og="http://opengraphprotocol.org/schema/" xmlns:fb="http://www.facebook.com/2008/fbml"';
}
 add_filter('language_attributes', 'add_opengraph_doctype');

 function insert_fb_in_head() {

 $og_title = get_post_meta( get_the_ID(), '_yoast_wpseo_title', true);

 $og_description = get_post_meta( get_the_ID(), '_yoast_wpseo_metadesc', true);

 if( ! $og_title)   
    $og_title = get_the_title();

 if( ! $og_description){    
    $og_description = get_the_excerpt();
    if ( strlen($og_description) > 156)
        $og_description = substr( get_the_excerpt(), 0, 153) . '...';
}

echo ('<meta property="og:title" content="' . $og_title . '"/>' . PHP_EOL);
echo ('<meta property="og:type" content="article"/>' . PHP_EOL);
echo ('<meta property="og:url" content="' . get_permalink() . '"/>' . PHP_EOL);
echo ('<meta property="og:site_name" content="Sea-Tac Noise Information"/>' . PHP_EOL);
echo ('<meta property="og:description" content="' . strip_tags( $og_description) . '"/>' . PHP_EOL);

  //dpm(    has_post_thumbnail( $post->ID ));
    //$thumbnail_src = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full' );
    //dpm($thumbnail_src);

if( has_post_thumbnail( $post->ID )) { //the post has a featured image, use a default image
    $thumbnail_src = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full' );
    //dpm($thumbnail_src);
    echo ('<meta property="og:image" content="' . esc_attr( $thumbnail_src[0] ) . '"/>' . PHP_EOL);
    echo ('<meta property="og:image:width" content="' . esc_attr( $thumbnail_src[1] ) . '"/>' . PHP_EOL);
    echo ('<meta property="og:image:height" content="' . esc_attr( $thumbnail_src[2] ) . '"/>' . PHP_EOL);      
}

$default_image="http://example.com/wp-content/uploads/myimage.png";             echo ('<meta property="og:image" content="' . $default_image . '"/>' . PHP_EOL);
    echo ('<meta property="og:image:width" content="250"/>' . PHP_EOL);
    echo ('<meta property="og:image:height" content="250"/>' . PHP_EOL);        
  }
  add_action( 'wp_head', 'insert_fb_in_head', 5 );
  • What is the purpose of a future publish date if you want to share and link to it before it’s published? – Milo Dec 6 at 23:01
  • We're used the post date as part of a calendar application. Users should still be able to click on the post and view it to see the notes entered about the post. – jchwebdev Dec 6 at 23:16
  • 1
    Save the calendar date in post meta, don’t use publish date for this. – Milo Dec 6 at 23:24
  • Anyone else know the -real- answer? – jchwebdev Dec 7 at 0:40
  • Milo's correct. You're misusing the post date. If you have date information unrelated to the publication of the post, it should be stored as meta. – Jacob Peattie Dec 7 at 4:46

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.