フォーラムへの返信

2件の返信を表示中 - 1 - 2件目 (全2件中)
  • フォーラム: 使い方全般
    返信が含まれるトピック: カスタム投稿本文の抜粋をTOPページに表示したい
    トピック投稿者 158158

    (@158158-1)

    pluto1234様、ありがとうございました。
    お返事が遅くなりまして申し訳ございません。
    いただいたスクリプトを試してみましたが、解決できませんでした。
    サムネール画像と抜粋文の表示はあきらめて、
    post_contentで本文全てを抜き出し、imgの大きさをcssで変える等の
    工夫をしてみます。
    ありがとうございました。

    フォーラム: 使い方全般
    返信が含まれるトピック: カスタム投稿本文の抜粋をTOPページに表示したい
    トピック投稿者 158158

    (@158158-1)

    レスありがとうございました。回答遅くなりまして申し訳ございません。
    excerptは登録しています。
    カスタム投稿タイプのカテゴリーとタクソノミーの全設定(function.php)は以下の通りです。

    add_action( 'init', 'create_post_type', 0 );
    function create_post_type() {
    	register_post_type( 'products',
    		array(
    			'labels' => array(
    			'name' => '商品情報',
    			'singular_name' => '商品情報一覧',
    			'add_new_item' => '新しい商品の追加',
    			),
    			'public' => true,
    			'publicly_queryable' => true,
    			'query_var' => true,
    			'exclude_from_search' => false,
    			'show_in_nav_menus' => true,
    			'menu_position' =>8,
    			'has_archive' => 'products/archive/',
    			'supports' => array('title','editor','excerpt','thumbnail','comments',)
    		)
    	);
    	register_taxonomy(
    		'products-cat',
    		'products',
    		array(
    			'hierarchical' =>true,
    			'update_count_callback' => '_update_post_term_count',
    			'label' => '商品情報カテゴリー',
    			'singular_label' => '商品情報カテゴリー',
    			'public' => true,
    			'show_ui' => true,
    			'menu-order' => true,
    		)
    	);
    }
    
    add_action( 'generate_rewrite_rules', 'my_rewrite' );
    function my_rewrite( $wp_rewrite ){
    	$taxonomies = get_taxonomies();
    	$taxonomies = array_slice($taxonomies,4,count($taxonomies)-1);
    	foreach ( $taxonomies as $taxonomy ) :
    		$post_types = get_taxonomy($taxonomy)->object_type;
    
    	foreach ($post_types as $post_type){
    		$new_rules[$post_type.'/'.$taxonomy.'/(.+?)/?$'] = 'index.php?taxonomy='.$taxonomy.'&term='.$wp_rewrite->preg_index(1);
    	}
    		$wp_rewrite->rules = array_merge($new_rules, $wp_rewrite->rules);
    	endforeach;
    }

    未だ解決に至らず困っております。
    よろしくお願い致します。

2件の返信を表示中 - 1 - 2件目 (全2件中)