created: 2021/08/22 modified: 2021/09/14
初めに
ファイル:Cocoon childのfunctions.php
関数の分類コード:03xx
ソース
定型文章を共用記事へ埋め込む
①get_post($id)の$idが上手く効かないので、get_post()から特定のタグを持つ記事取得のコードにしました。
//<--- 0301
add_shortcode('mysc_paid_variation', 'my_paid_variation');
function my_paid_variation($atts){
$args = array(
'posts_per_page' => 100,
'post_type' => 'post',
'post_status' => 'private'
);
$ps = get_posts( $args );
if( $ps ):
foreach( $ps as $p ):
if( has_tag("9901fixed",$p) ):
$ret = my_get_block_paragraph_begin();
$ret .= "<p>";
$ret .= $p->post_content;
$ret .= "</p>";
$ret .= my_get_block_paragraph_end();
endif;
endforeach;
endif;
return $ret;
}
// 0301 --->
メールアドレス: