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 );