web-dev-qa-db-ja.com

ショートコードで表示する項目数を問い合わせる

カスタム投稿タイプ(ポートフォリオ)を表示するショートコードを作成しています。表示する項目数を追加するための別のオプションを追加します。これは私が今持っているものですが、それはすべてのアイテムを示しています、そして私は 'items' shortcode_attを追加する必要がありますが、後でクエリでそれを呼び出す方法がわからない。ありがとうございました!!

add_shortcode( 'type_portfolio', function( $atts, $content = null ){
$atts = shortcode_atts(
array(
'column' => '3',
'category' => '0'
), $atts);

extract($atts);

$args = array(
'posts_per_page' => -1,
'post_type'      =>  'fen_portfolio'
);

if(  $category > '0' ){
$args['tax_query'] = array(
  array(
    'posts_per_page' => -1,
    'taxonomy' => 'cat_portfolio',
    'field' => 'term_id',
    'terms' => $category
    )
  );
 }

$portfolios = get_posts( $args );
1
Cynthia Lara
add_shortcode( 'type_portfolio', function( $atts, $content = null ){
$atts = shortcode_atts(
array(
'column' => '3',
'category' => '0',
'ppp' => -1
), $atts);

extract($atts);

$args = array(
'posts_per_page' => $ppp,
'post_type'      =>  'fen_portfolio'
);

if(  $category > '0' ){
$args['tax_query'] = array(
  array(
    'posts_per_page' => -1,
    'taxonomy' => 'cat_portfolio',
    'field' => 'term_id',
    'terms' => $category
    )
  );
 }

$portfolios = get_posts( $args );
2
D. Dan