• 07-04-2022, 04:32:31
    #1
    ID'si 5 olan kategoriye .css dosyası eklemek istiyorum. Bunu functions.php'ye kod ekleyerek ya da kategorinin kendine özel şablonu olan category-5.php'ye ekleyerek yapabilirim. Doğru kod nasıl olmalı onu bilmiyorum. <link rel="stylesheet" href="mystyle.css"> şeklinde ekleyince eklediğim yerde görünüyor, Benim head içerisine ekleyecek bir koda ihtiyacım var yani wp_enqueue_scripts kancası ile yapmam gerekiyor.

    function custom_style() {
        wp_enqueue_style( 'my-css', get_stylesheet_directory_uri() . 'css/style.css' );
    }
    add_action( 'wp_enqueue_scripts', 'custom_style' );
  • 07-04-2022, 04:41:53
    #2
    Buyrun hocam.

    function custom_style()
    {
      $cat_id = 5;
    
      if (is_category() && (is_category($cat_id))) {
        wp_enqueue_style('my-css', get_stylesheet_directory_uri() . 'css/style.css');
      }
    }
    add_action( 'wp_enqueue_scripts', 'custom_style' );
    • SkyGhostAir
    • stkersln
    • oguzh4nk
    SkyGhostAir, stkersln ve oguzh4nk bunu beğendi.
    3 kişi bunu beğendi.
  • 07-04-2022, 04:50:50
    #3
    CanYildirim adlı üyeden alıntı: mesajı görüntüle
    Buyrun hocam.

    function custom_style()
    {
      $cat_id = 5;
    
      if (is_category() && (is_category($cat_id))) {
        wp_enqueue_style('my-css', get_stylesheet_directory_uri() . 'css/style.css');
      }
    }
    add_action( 'wp_enqueue_scripts', 'custom_style' );
    Çok teşekkür ederim hocam. Birden fazla kategoriyi ID olarak seçmek istesem ne yapmam gerekirdi acaba?
  • 07-04-2022, 05:02:47
    #4
    SkyGhostAir adlı üyeden alıntı: mesajı görüntüle
    Çok teşekkür ederim hocam. Birden fazla kategoriyi ID olarak seçmek istesem ne yapmam gerekirdi acaba?
    is_category(array(5, 'cat-slug', 7))