採用サイト制作に最適なWordPressテーマ「ISSUE」の機能概要

ワードプレステーマ別

TCDテーマPreciousで商品カテゴリーのスラッグを変更する方法

Q.商品カテゴリーのスラッグを変更したい

A.下記のphpファイルの該当箇所を編集します

編集するファイル:function.php
編集する箇所:

  
//カスタム分類を追加
  $args = array(
    'label' => __('Product Category', 'tcd-w'),
    'labels' => array(
      'name' => __('Product Category', 'tcd-w'),
      'singular_name' => __('Product Category', 'tcd-w'),
      'search_items' => __('Search Items', 'tcd-w'),
      'popular_items' => __('Popular Items', 'tcd-w'),
      'all_items' => __('All Items', 'tcd-w'),
      'parent_item' => __('Parent Item', 'tcd-w'),
      'edit_item' => __('Edit Item', 'tcd-w'),
      'update_item' => __('Update Item', 'tcd-w'),
      'add_new_item' => __('Add New Item', 'tcd-w'),
      'new_item_name' => __('New Item Name', 'tcd-w'),
    ),
    'public' => true,
    'show_ui' => true,
    'show_admin_column' => true,
    'hierarchical' => true,
  );
  register_taxonomy('product-cat', 'product', $args);
// 商品アーカイブページの表示件数を変更
function change_product_num($wp_query){
  $options = get_desing_plus_option();
  $product_archive_num = $options['product_archive_num'];
  if(!is_admin() && $wp_query->is_main_query() && $wp_query->is_post_type_archive('product')){
    $wp_query->set('posts_per_page',$product_archive_num);
  }
}
add_action('pre_get_posts', 'change_product_num');

function change_product_num2($wp_query){
  $options = get_desing_plus_option();
  $product_archive_num = $options['product_archive_num'];
  if(!is_admin() && $wp_query->is_main_query() && $wp_query->is_tax('product-cat')){
    $wp_query->set('posts_per_page',$product_archive_num);
  }
}
add_action('pre_get_posts', 'change_product_num2');

デフォルトのproduct-cat(2箇所)を任意のものに変更します。

TCDテーマPrecious「商品」名称変更に関連する記事

※:アップデートでテーマオプションより変更が可能になりました。

この記事は役に立ちましたか?

もし参考になりましたら、下のボタンで教えてください。
今後の記事作成の参考とさせて頂きます!

同じテーマのカスタマイズ記事