忍者ブログ
28 January

タクソノミーアーカイブページで管理画面の順番通りにする


https://web.studio-nanntoca.com/wordpress/847
ありがたいコードを引用
 functions.phpにかく
function cat_products_sort_order($query)
{
    if (is_admin() || !$query->is_main_query()) {
        return;
    }
    if ($query->is_tax('cat_products')) {
        $query->set('orderby', 'menu_order');
        $query->set('order', 'ASC');
    }
}
add_action('pre_get_posts', 'cat_products_sort_order');
PR
02 August

所属するターム一覧 class名をスラッグで作る 

<div class="voice_cat cat_name">
   <?php 
   // 投稿に紐づくタームの一覧を表示
   $taxonomy_slug = 'cat_voice'; // 任意のタクソノミースラッグを指定
   $category_terms = wp_get_object_terms($post->ID, $taxonomy_slug); // タームの情報を取得
   if (!empty($category_terms)) { // 変数が空でなければ true
      if (!is_wp_error($category_terms)) { // 変数が WordPress Error でなければ true
         foreach ($category_terms as $category_term) { // タームのループを開始
            // タームのスラッグをクラスに追加
            echo '<a href="' . get_term_link($category_term->slug, $taxonomy_slug) . '" class="label label-' . esc_attr($category_term->slug) . '">' . esc_html($category_term->name) . '</a>'; // タームをリンク付きで表示
         } // ループの終了
      }
   }
   ?>
</div>
28 March

CF7 完了ページへとばす

ありがたいコードをコピペ
https://web-dev.tech/wordpress/plugin/contact-form-7-thanks-page/


<script>
document.addEventListener( 'wpcf7mailsent', function( event ) {
  location = 'ここに完了ページのURLを記入';
}, false );
</script>
15 October

wwwに統一 htaccess

# wwwありに統一
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L]
</IfModule>


wwwありとか今どきいらなくね?
いちいち書かなくちゃいけないのめんどいんだけど…
すげー無意味
ある必要性がまったくわからない
        
  • 1
  • 2
  • 3