رفتن به مطلب

مشکل نمایش برچسبها در custom-type


پست های پیشنهاد شده

سلام چند وقت پیش مشکلی با ابزارک قالب و custom-type داشتم که به کمک آقا ایمان و یکی از اقواممون حل شد الان تو همین نوشته های سفارشیم برچسب ندارم یعنی ابزارک برچسبها تو صفحه ارسال نوشته نیست

من کدزیر رو به فایلم اضافه کردم که برچسبهام اومد


'taxonomies' => array('post_tag')

الان ابزارک برچسب به صفحه اضافه شده وقتی برچسبی رو وارد میکنم اون رو ذخیره میکنه اما وقتی به قسمت برچسب های کاستوم تایپم میرم با وجود اینکه برچسب ها اونجا ثبت شدن هیچ کدومشون به پستی که برچسب خوردن نمایش داده نمیشن

یعنی برچسب وجود داره ولی یافت نمیشه یا همون صفحه ای که نوشته چیزی یافت نشد

لینک به ارسال

شما برچسب پیشفرض وردپرس رو ست کردید

تاکسونامی هم تعریف کردید؟

http://forum.wp-parsi.com/tutorials/article/6-%D9%BE%D8%B3%D8%AA-%D8%B3%D9%81%D8%A7%D8%B1%D8%B4%DB%8C-%D8%B4%D8%B1%D9%88%D8%B9/

لینک به ارسال

آقا پارسا این فایل برای خود پوستم هست که تو خطهای آخر من اون کد رو اضافه کردم

برچسب ها رو آورد قسمتی هم با نام برچسب ها تو منوی سمت راست پیشخوان تو کاستوم تایپم آورد حتی برچسب ها تو این قسمت هم ذخیره میشن اما به اون مطلبی که برچسب خوردن نمایش داده نمیشن


function ItemPostType()
{
register_post_type( 'exeo-item',
array(
'labels' => array(
'name' => 'Items',
'singular_name' => 'Item',
'add_new' => 'Add new',
'add_new_item' => 'Add new item',
'edit_item' => 'Edit item',
'new_item' => 'New item',
'not_found' => 'No items found',
'not_found_in_trash' => 'No items found in Trash',
'menu_name' => 'Items',
),
'description' => 'Manipulating with items',
'public' => true,
'show_in_nav_menus' => true,
'supports' => array(
'title',
'thumbnail',
'editor',
'excerpt',
'page-attributes',
'comments',
),
'show_ui' => true,
'show_in_menu' => true,
'menu_position' => $GLOBALS['CustomTypes']['dir-item'],
'has_archive' => true,
'query_var' => 'dir-item',
'rewrite' => array('slug' => 'item'),
'capability_type' => 'exeo-item',
'map_meta_cap' => true,
'taxonomies' => array('post_tag')
)
);
ItemTaxonomies();
flush_rewrite_rules(false);
}

لینک به ارسال

بخش تگ پیشفرض وردپرس مربوط به نوع post هست

بهتره تاکسونامی تعریف کنید

لینک به ارسال

ممنون اون آموزش هم توش قسمت برچسب ها رو توضیح داده بودید اما من نمیدونم کدها رو کجا بزارم الان امتحان کردم خطا داد اگه براتون زحمت نمیشه تو کدهای پوسته من بزاریدبرچسب ها رو

ببخشید

لینک به ارسال

پوستم سه تا کاستوم تایپ داره آیتم و دسته بندی و موقعیت

راستش آقا پارسا از این چیزایی که میگید من هیچی سر در نمیارم وقتی این کدها رو میبینم چشمام درد میگیره

کل فایل من اینه

function ItemPostType()

{

register_post_type( 'exeo-item',

array(

'labels' => array(

'name' => 'Items',

'singular_name' => 'Item',

'add_new' => 'Add new',

'add_new_item' => 'Add new item',

'edit_item' => 'Edit item',

'new_item' => 'New item',

'not_found' => 'No items found',

'not_found_in_trash' => 'No items found in Trash',

'menu_name' => 'Items',

),

'description' => 'Manipulating with items',

'public' => true,

'show_in_nav_menus' => true,

'supports' => array(

'title',

'thumbnail',

'editor',

'excerpt',

'page-attributes',

'comments',

),

'show_ui' => true,

'show_in_menu' => true,

'menu_position' => $GLOBALS['exeoThemeCustomTypes']['dir-item'],

'has_archive' => true,

'query_var' => 'dir-item',

'rewrite' => array('slug' => 'item'),

'capability_type' => 'exeo-item'

)

);

ItemTaxonomies();

flush_rewrite_rules(false);

}

function ItemTaxonomies()

{

register_taxonomy( 'exeo-item-category', array( 'exeo-item' ), array(

'hierarchical' => true,

'labels' => array(

'name' => 'Item Categories',

'singular_name' => _x( 'Category', 'taxonomy singular name', 'exeo'),

'search_items' => __( 'Search Category', 'exeo'),

'all_items' => __( 'All Categories', 'exeo'),

'parent_item' => __( 'Parent Category', 'exeo'),

'parent_item_colon' => __( 'Parent Category:', 'exeo'),

'edit_item' => __( 'Edit Category', 'exeo'),

'update_item' => __( 'Update Category', 'exeo'),

'add_new_item' => __( 'Add New Category', 'exeo'),

'new_item_name' => __( 'New Category Name', 'exeo'),

),

'show_ui' => true,

'rewrite' => array( 'slug' => 'cat' ),

'query_var' => 'dir-item-category',

'capabilities' => array(

'assign_terms' => 'assign_dir_category'

)

));

register_taxonomy( 'exeo-item-location', array( 'exeo-item' ), array(

'hierarchical' => true,

'labels' => array(

'name' => 'Item Locations',

'singular_name' => _x( 'Location', 'taxonomy singular name', 'exeo'),

'search_items' => __( 'Search Location', 'exeo'),

'all_items' => __( 'All Locations', 'exeo'),

'parent_item' => __( 'Parent Location', 'exeo'),

'parent_item_colon' => __( 'Parent Location:', 'exeo'),

'edit_item' => __( 'Edit Location', 'exeo'),

'update_item' => __( 'Update Location', 'exeo'),

'add_new_item' => __( 'Add New Location', 'exeo'),

'new_item_name' => __( 'New Location Name', 'exeo'),

),

'show_ui' => true,

'rewrite' => false,

'query_var' => false,

'capabilities' => array(

'assign_terms' => 'assign_dir_location'

)

));

}

add_action( 'init', 'ItemPostType');

function ItemFeaturedImageMetabox()

{

global $wp_meta_boxes;

// only if exist

if(isset($wp_meta_boxes['exeo-item'])){

foreach ($wp_meta_boxes['exeo-item'] as $contextName => $context) {

foreach ($context as $boxesName => $boxes) {

foreach ($boxes as $boxName => $box) {

if($boxName == 'postimagediv'){

remove_meta_box( 'postimagediv', 'exeo-item', 'side' );

add_meta_box('postimagediv', 'Image for item', 'post_thumbnail_meta_box', 'exeo-item', 'normal', 'high');

}

}

}

}

}

}

add_action('do_meta_boxes', 'ItemFeaturedImageMetabox',1);

$dirItemOptions = new WPAlchemy_MetaBox(array

(

'id' => '_exeo-item',

'title' => __('Options for item', 'exeo'),

'types' => array('exeo-item'),

'context' => 'normal',

'priority' => 'core',

'config' => dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.neon',

'js' => dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.js',

));

function ItemChangeColumns($cols)

{

$cols = array(

'cb' => '<input type="checkbox" />',

'title' => __( 'Title', 'exeo'),

'author' => __('Author', 'exeo'),

'thumbnail' => __( 'Image', 'exeo'),

'address' => __( 'Address', 'exeo'),

'category' => __( 'Categories', 'exeo'),

'exeo-item-location' => __( 'Locations', 'exeo'),

);

return $cols;

}

add_filter( "manage_exeo-item_posts_columns", "ItemChangeColumns" );

function ItemCustomColumns($column, $post_id)

{

global $dirItemOptions;

$options = $dirItemOptions->the_meta();

switch($column){

case "exeo-item-location":

$terms = get_the_terms($post_id, 'exeo-item-location');

if(!empty($terms)){

foreach($terms as $term){

echo "<a href='".get_term_link($term, 'exeo-item-location')."' rel='tag'>{$term->name}</p>";

}

}else{

//echo "<p>No locations</p>";

}

break;

case "address":

if(isset($options['address'])){

echo $options['address'];

}

break;

}

}

add_action( "manage_posts_custom_column", "exeoDirItemCustomColumns", 10, 2);

/************************** Add meta ICON *****************************************/

add_action( 'exeo-item-category_edit_form_fields', 'edit_dir_item_category', 10, 2);

add_action( 'exeo-item-category_add_form_fields', 'add_dir_item_category', 10, 2);

function edit_dir_item_category($tag, $taxonomy)

{

$icon = get_option( 'exeo_dir_item_category_'.$tag->term_id.'_icon', '' );

$marker = get_option( 'exeo_dir_item_category_'.$tag->term_id.'_marker', '' );

$excerpt = get_option( 'exeo_dir_item_category_'.$tag->term_id.'_excerpt', '' );

?>

<tr class="form-field">

<th scope="row" valign="top"><label for="exeo_dir_item_category_excerpt">Excerpt</label></th>

<td>

<textarea name="exeo_dir_item_category_excerpt" id="exeo_dir_item_category_excerpt" cols="30" rows="5"><?php echo $excerpt; ?></textarea>

</td>

</tr>

<tr class="form-field">

<th scope="row" valign="top"><label for="exeo_dir_item_category_icon">Icon</label></th>

<td>

<input type="text" name="exeo_dir_item_category_icon" id="exeo_dir_item_category_icon" value="<?php echo $icon; ?>" style="width: 80%;"/>

<input type="button" value="Select Image" class="media-select" id="exeo_dir_item_category_icon_selectMedia" name="exeo_dir_item_category_icon_selectMedia" style="width: 15%;">

<br />

<p class="description">Icon for category</p>

</td>

</tr>

<tr class="form-field">

<th scope="row" valign="top"><label for="exeo_dir_item_category_marker">Map Marker</label></th>

<td>

<input type="text" name="exeo_dir_item_category_marker" id="exeo_dir_item_category_marker" value="<?php echo $marker; ?>" style="width: 80%;"/>

<input type="button" value="Select Image" class="media-select" id="exeo_dir_item_category_marker_selectMedia" name="exeo_dir_item_category_marker_selectMedia" style="width: 15%;">

<br />

<p class="description">Marker image in map for category</p>

</td>

</tr>

<?php

}

function add_dir_item_category($tag)

{

?>

<div class="form-field">

<label for="exeo_dir_item_category_excerpt">Excerpt</label>

<textarea name="exeo_dir_item_category_excerpt" id="exeo_dir_item_category_excerpt" cols="30" rows="5"></textarea>

</div>

<div class="form-field">

<label for="exeo_dir_item_category_icon">Icon</label>

<input type="text" name="exeo_dir_item_category_icon" id="exeo_dir_item_category_icon" value="" style="width: 80%;"/>

<input type="button" value="Select Image" class="media-select" id="exeo_dir_item_category_icon_selectMedia" name="exeo_dir_item_category_icon_selectMedia" style="width: 15%;">

<br />

<p class="description">Icon for category</p>

</div>

<div class="form-field">

<label for="exeo_dir_item_category_marker">Map Marker</label>

<input type="text" name="exeo_dir_item_category_marker" id="exeo_dir_item_category_marker" value="" style="width: 80%;"/>

<input type="button" value="Select Image" class="media-select" id="exeo_dir_item_category_marker_selectMedia" name="exeo_dir_item_category_marker_selectMedia" style="width: 15%;">

<br />

<p class="description">Marker image in map for category</p>

</div>

<?php

}

add_action( 'created_exeo-item-category', 'save_dir_item_category', 10, 2);

add_action( 'edited_exeo-item-category', 'save_dir_item_category', 10, 2);

function save_dir_item_category($term_id, $tt_id)

{

if (!$term_id) return;

if (isset($_POST['exeo_dir_item_category_excerpt'])){

$name = 'exeo_dir_item_category_' .$term_id. '_excerpt';

update_option( $name, $_POST['exeo_dir_item_category_excerpt'] );

}

if (isset($_POST['exeo_dir_item_category_icon'])){

$name = 'exeo_dir_item_category_' .$term_id. '_icon';

update_option( $name, $_POST['exeo_dir_item_category_icon'] );

}

if (isset($_POST['exeo_dir_item_category_marker'])){

$name = 'exeo_dir_item_category_' .$term_id. '_marker';

update_option( $name, $_POST['exeo_dir_item_category_marker'] );

}

}

add_action( 'deleted_term_taxonomy', 'delete_dir_item_category' );

function delete_dir_item_category($id)

{

delete_option( 'exeo_dir_item_category_'.$id.'_excerpt' );

delete_option( 'exeo_dir_item_category_'.$id.'_icon' );

delete_option( 'exeo_dir_item_category_'.$id.'_marker' );

}

// TABLE COLUMNS

add_filter("manage_edit-exeo-item-category_columns", 'dir_item_category_columns');

function dir_item_category_columns($category_columns) {

$new_columns = array(

'cb' => '<input type="checkbox" />',

'name' => __('Name', 'exeo'),

'description' => __('Description', 'exeo'),

'item_excerpt' => __('Excerpt', 'exeo'),

'icon' => __('Icon', 'exeo'),

'marker' => __('Marker', 'exeo'),

'slug' => __('Slug', 'exeo'),

'posts' => __('Items', 'exeo'),

);

return $new_columns;

}

add_filter("manage_exeo-item-category_custom_column", 'manage_dir_item_category_columns', 10, 3);

function manage_dir_item_category_columns($out, $column_name, $cat_id) {

$icon = get_option( 'exeo_dir_item_category_'.$cat_id.'_icon', '' );

$marker = get_option( 'exeo_dir_item_category_'.$cat_id.'_marker', '' );

$excerpt = get_option( 'exeo_dir_item_category_'.$cat_id.'_excerpt', '' );

switch ($column_name) {

case 'item_excerpt':

if($excerpt && !empty($excerpt)){

$out .= $excerpt;

}

break;

case 'icon':

if(!empty($icon)){

$out .= '<img src="'.$icon.'" alt="" width="50" height="50">';

}

break;

case 'marker':

if(!empty($marker)){

$out .= '<img src="'.$marker.'" alt="" width="50" height="50">';

}

break;

default:

break;

}

return $out;

}

function exeoDirItemSortableColumns()

{

return array(

'title'=> 'title',

'category'=> 'category'

);

}

add_filter( "manage_edit-exeo-item_sortable_columns", "exeoDirItemSortableColumns" );

?>

لینک به ارسال

به بخش supports برچسب ها رو اضافه کنید مثلا:

'supports' => array('title', 'thumbnail', 'excerpt', 'comments', 'custom-fields', 'tags')

به تاکسونومی هم همونطور که اضافه کردید درسته

این هم میشه:

'taxonomies' => array('category', 'post_tag') 

اگر نشد این رو به کدهاتون اضافه کنید ببینید برچسبها براتون اضافه و درستمیشن؟

add_action( 'init', 'create_tag_taxonomies', 0 );

//create two taxonomies, genres and tags for the post type "tag"

function create_tag_taxonomies()

{

// Add new taxonomy, NOT hierarchical (like tags)

$labels = array(

'name' => _x( 'Tags', 'taxonomy general name' ),

'singular_name' => _x( 'Tag', 'taxonomy singular name' ),

'search_items' => __( 'Search Tags' ),

'popular_items' => __( 'Popular Tags' ),

'all_items' => __( 'All Tags' ),

'parent_item' => null,

'parent_item_colon' => null,

'edit_item' => __( 'Edit Tag' ),

'update_item' => __( 'Update Tag' ),

'add_new_item' => __( 'Add New Tag' ),

'new_item_name' => __( 'New Tag Name' ),

'separate_items_with_commas' => __( 'Separate tags with commas' ),

'add_or_remove_items' => __( 'Add or remove tags' ),

'choose_from_most_used' => __( 'Choose from the most used tags' ),

'menu_name' => __( 'Tags' ),

);

register_taxonomy('tag','exeo-item',array(

'hierarchical' => false,

'labels' => $labels,

'show_ui' => true,

'update_count_callback' => '_update_post_term_count',

'query_var' => true,

'rewrite' => array( 'slug' => 'tag' ),

));

}

لینک به ارسال

ممنون پارسا و مرتضی جان {گل}

معراج جان تغییراتی که آقا مرتضی گفتن رو انجام بده اگه باز هم نتونستی روشهای زیر رو هم تست کن

این افزونه رو نصب کن من کار نکردم اما تمام نوشته های ویژت رو لیست میکنه و میتونی از همین قبیل تغییرات روشون داشته باشی

اگه ج نداد دستور زیر رو به فانکشن پوستت اضافه کن(functions.php تو مسیر اصلی پوشه پوسته)


add_filter('pre_get_posts', 'query_post_type');
function query_post_type($query) {
if ( is_category() || is_tag() && empty( $query->query_vars['suppress_filters'] ) ) {
$post_type = get_query_var('post_type');
if($post_type)
$post_type = $post_type;
else
$post_type = array('post','exeo-item');
$query->set('post_type',$post_type);
return $query;
}
}

دستور زیر مطابق با پست اولت هست اون کدی که خودت اضافه کرده بودی باید تو فایلت باشه برای باقی نوشته های ویژت هم به همین ترتیب عمل کن اما تو خط هشتم اسمی که برای custom-type تعیین شده رو جایگزین کن

اگه باز هم موفق نشدی یوزر پسورد هاستت رو به جیمیلم بفرست .

لینک به ارسال

به گفتگو بپیوندید

هم اکنون می توانید مطلب خود را ارسال نمایید و بعداً ثبت نام کنید. اگر حساب کاربری دارید، برای ارسال با حساب کاربری خود اکنون وارد شوید .

مهمان
ارسال پاسخ به این موضوع ...

×   شما در حال چسباندن محتوایی با قالب بندی هستید.   حذف قالب بندی

  تنها استفاده از 75 اموجی مجاز می باشد.

×   لینک شما به صورت اتوماتیک جای گذاری شد.   نمایش به صورت لینک

×   محتوای قبلی شما بازگردانی شد.   پاک کردن محتوای ویرایشگر

×   شما مستقیما نمی توانید تصویر خود را قرار دهید. یا آن را اینجا بارگذاری کنید یا از یک URL قرار دهید.

×
×
  • اضافه کردن...