• 26-09-2016, 08:53:36
    #1
    Slm Arkadaslar,

    ben wordpresste Kategoriye özel alan ekledim internette buldugum verilerle ve bu özel alana ekledigim veriyi sitede göstermek istiyorum. Yardiminiz icin simdiden tsk ederim.

    functions.php dosyasina su kodlari ekledim

    /** Add Custom Field To Category Form */
    add_action('category_add_form_fields', 'category_form_custom_field_add', 10);
    add_action('category_edit_form_fields', 'category_form_custom_field_edit', 10, 2);
    
    function category_form_custom_field_add($taxonomy)
    {
        ?>
        <div class="form-field">
            <label for="category_custom_order">Custom Order</label>
            <input name="category_custom_order" id="category_custom_order" type="text" value="" size="40" aria-required="true"/>
            <p class="description">Enter a custom order value.</p>
        </div>
        <?php
    }
    
    function category_form_custom_field_edit($tag, $taxonomy)
    {
    
        $option_name = 'category_custom_order_' . $tag->term_id;
        $category_custom_order = get_option($option_name);
    
        ?>
        <tr class="form-field">
            <th scope="row" valign="top"><label for="category_custom_order">Custom Order</label></th>
            <td>
                <input type="text" name="category_custom_order" id="category_custom_order" value="<?php echo esc_attr($category_custom_order) ? esc_attr($category_custom_order) : ''; ?>" size="40" aria-required="true"/>
                <p class="description">Enter a custom order value.</p>
            </td>
        </tr>
        <?php
    }
    
    /** Save Custom Field Of Category Form */
    add_action('created_category', 'category_form_custom_field_save', 10, 2);
    add_action('edited_category', 'category_form_custom_field_save', 10, 2);
    
    function category_form_custom_field_save($term_id, $tt_id)
    {
    
        if (isset($_POST['category_custom_order'])) {
            $option_name = 'category_custom_order_' . $term_id;
            update_option($option_name, $_POST['category_custom_order']);
        }
    }
    Saygilarimla
  • 26-09-2016, 11:41:36
    #2
    pek detaylı inceleyemedim ama böyle bir denermisiniz.

    <?php echo get_option( 'category_custom_order_' . $cat->term_id ); ?>
  • 26-09-2016, 13:05:21
    #3
    Tsk ederim hocam ama maalesef olmadi

    _SecreT_ adlı üyeden alıntı: mesajı görüntüle
    pek detaylı inceleyemedim ama böyle bir denermisiniz.

    <?php echo get_option( 'category_custom_order_' . $cat->term_id ); ?>
  • 26-09-2016, 13:05:53
    #4
    skype:yakup_sener ekleyin yardımcı olayım hocam
  • 26-09-2016, 14:12:44
    #5
    ekledim hocam
    _SecreT_ adlı üyeden alıntı: mesajı görüntüle
    skype:yakup_sener ekleyin yardımcı olayım hocam
  • 27-09-2016, 14:15:52
    #6
    WWT
    Üyeliği durduruldu
    advanced custom fields eklentisi ile kodlarla uğraşmadan panel üzerinden istediğiniz yere özel alan ekleyebilir, the_field('alan-ismi'); şeklinde istediğiniz yerde gösterebilirsiniz.

    konudan uzak olduğunuzu varsayarak önerim budur