// 2011.07.11: [get_post_link query="ID (tag_id) " target="_blank" plink="link name within page" title="instead of title name" ] // Wordpressの投稿・固定ページへのリンクを張る // Autolink for Post and Pages in Wordpress // 2011.07.13: If the status of the page or post is not "publish", the link information will be removed (Only title name). // 2011.08.03: 1.1: added new attribute of link in page. (ex. plink="example" --> hogehoge#example) // Parse parameters extract(shortcode_atts(array('query' => '', 'target'=> '', 'plink' => '', 'title'=>''), $atts)); $query = attribute_escape(strip_tags(html_entity_decode($query,ENT_QUOTES))); $target = attribute_escape(strip_tags(html_entity_decode($target,ENT_QUOTES))); $plink = attribute_escape(strip_tags(html_entity_decode($plink,ENT_QUOTES))); $title = attribute_escape(strip_tags(html_entity_decode($title,ENT_QUOTES))); if (empty($query)) return ''; $c_post = get_post($query); // 2011.07.13: Fixed in case of empty post. if( $c_post ){ if( $c_post->post_status != "publish") echo attribute_escape($c_post->post_title); else{ echo ''; // 2011.08.03 if(!empty($title)) echo $title; else echo attribute_escape($c_post->post_title); echo ''; } }