eepersian 156 ارسال شده در خرداد 93 گزارش بازنشر ارسال شده در خرداد 93 با سلام 2 نوع پست سفارشی به نام های publication و news ایجاد کردم+2 نوع taxonomy هم به نام های Publication Categories و newscategories ایجاد کردم .مشکلات :1- فایل single-publication.php رو ایجاد کردم و نوشته های تکی publication رو توش بدون مشکل نشون میدم ولی با نمایش دسته بندی های نوشته ها مشکل دارم 2- فایلی که مثل صفحه ی index یا home بتونم لیست پست های سفارشی رو توش قرار بدم چطوریه ؟ آیا باید از template سفارشی استفاده کنم یا راه بهتری داره ؟3- برای دسته بندی های Publication Categories و newscategories چطور صفحه ای مثل category.php درست کنم که باکلیک روی یک دسته بندی سفارشی لیست نوشته های اون دسته بندی رو نمایش بدم ؟4- کلاً چطور می تونم هر چیزی رو که برای نوشته ها و دسته بندی های معمولی وجود داره رو برای نوشته و دسته بندی های سفارشی ام داشته باشم ؟فایل functions.php رو در زیر می تونید مشاهده کنید:<?phprequire_once TEMPLATEPATH . '/custom/multiple-featured-images.php';add_action( 'wp_enqueue_scripts', 'enqueue_scripts_function' );function enqueue_scripts_function(){wp_register_script( 'jquery-1.3.2.js', get_stylesheet_directory_uri() . '/js/jquery-1.3.2.js' );wp_enqueue_script('jquery-1.3.2.js');}//Main Menuadd_action('init', 'register_my_menus');function register_my_menus() {register_nav_menus( array( 'maak-main-menu' => __('MAAK Main Menu') ) ); }//add_theme_support( 'post-thumbnails' );$args1 = array( 'id' => 'featured-image-2', 'post_type' => 'post', // Set this to post or page 'labels' => array( 'name' => 'Featured image 2', 'set' => 'Set featured image 2', 'remove' => 'Remove featured image 2', 'use' => 'Use as featured image 2', ) );$args2 = array( 'id' => 'featured-image-3', 'post_type' => 'post', // Set this to post or page 'labels' => array( 'name' => 'Featured image 3', 'set' => 'Set featured image 3', 'remove' => 'Remove featured image 3', 'use' => 'Use as featured image 3', ) ); $args4 = array( 'id' => 'featured-image-4', 'post_type' => 'post', // Set this to post or page 'labels' => array( 'name' => 'Featured image 4', 'set' => 'Set featured image 4', 'remove' => 'Remove featured image 4', 'use' => 'Use as featured image 4', ) ); $args5 = array( 'id' => 'featured-image-5', 'post_type' => 'post', // Set this to post or page 'labels' => array( 'name' => 'Featured image 5', 'set' => 'Set featured image 5', 'remove' => 'Remove featured image 5', 'use' => 'Use as featured image 5', ) ); $args6 = array( 'id' => 'featured-image-6', 'post_type' => 'post', // Set this to post or page 'labels' => array( 'name' => 'Featured image 6', 'set' => 'Set featured image 6', 'remove' => 'Remove featured image 6', 'use' => 'Use as featured image 6', ) ); $args7 = array( 'id' => 'featured-image-7', 'post_type' => 'post', // Set this to post or page 'labels' => array( 'name' => 'Featured image 7', 'set' => 'Set featured image 7', 'remove' => 'Remove featured image 7', 'use' => 'Use as featured image 7', ) ); $args8 = array( 'id' => 'featured-image-8', 'post_type' => 'post', // Set this to post or page 'labels' => array( 'name' => 'Featured image 8', 'set' => 'Set featured image 8', 'remove' => 'Remove featured image 8', 'use' => 'Use as featured image 8', ) ); $args9 = array( 'id' => 'featured-image-9', 'post_type' => 'post', // Set this to post or page 'labels' => array( 'name' => 'Featured image 9', 'set' => 'Set featured image 9', 'remove' => 'Remove featured image 9', 'use' => 'Use as featured image 9', ) ); $args10 = array( 'id' => 'featured-image-10', 'post_type' => 'post', // Set this to post or page 'labels' => array( 'name' => 'Featured image 10', 'set' => 'Set featured image 10', 'remove' => 'Remove featured image 10', 'use' => 'Use as featured image 10', ) ); new kdMultipleFeaturedImages( $args1 ); new kdMultipleFeaturedImages( $args2 ); new kdMultipleFeaturedImages( $args3 ); new kdMultipleFeaturedImages( $args4 ); new kdMultipleFeaturedImages( $args5 ); new kdMultipleFeaturedImages( $args6 ); new kdMultipleFeaturedImages( $args7 ); new kdMultipleFeaturedImages( $args8 );new kdMultipleFeaturedImages( $args9 ); new kdMultipleFeaturedImages( $args10 );add_action( 'init', 'register_cpt_publication' );function register_cpt_publication() { $labels = array( 'name' => _x( 'Publications', 'publication' ), 'singular_name' => _x( 'Publication', 'publication' ), 'add_new' => _x( 'Add New', 'publication' ), 'add_new_item' => _x( 'Add New Publication', 'publication' ), 'edit_item' => _x( 'Edit Publication', 'publication' ), 'new_item' => _x( 'New Publication', 'publication' ), 'view_item' => _x( 'View Publication', 'publication' ), 'search_items' => _x( 'Search Publications', 'publication' ), 'not_found' => _x( 'No publications found', 'publication' ), 'not_found_in_trash' => _x( 'No publications found in Trash', 'publication' ), 'parent_item_colon' => _x( 'Parent Publication:', 'publication' ), 'menu_name' => _x( 'Publications', 'publication' ), ); $args = array( 'labels' => $labels, 'hierarchical' => false, 'supports' => array( 'title', 'editor', 'excerpt', 'author', 'thumbnail', 'trackbacks', 'custom-fields', 'comments', 'revisions', 'page-attributes' ), 'taxonomies' => array( 'publication_category' ), 'public' => true, 'show_ui' => true, 'show_in_menu' => true, 'menu_position' => 5, 'show_in_nav_menus' => false, 'publicly_queryable' => true, 'exclude_from_search' => false, 'has_archive' => true, 'query_var' => true, 'can_export' => true, 'rewrite' => true, 'capability_type' => 'post' ); register_post_type( 'publication', $args );}add_action( 'init', 'register_taxonomy_publication_categories' );function register_taxonomy_Publication_Categories() { $labels = array( 'name' => _x( 'Publication Categories', 'Publication Categories' ), 'singular_name' => _x( 'Publication Categories', 'Publication Categories' ), 'search_items' => _x( 'Search Publication Categories', 'Publication Categories' ), 'popular_items' => _x( 'Popular Publication Categories', 'Publication Categories' ), 'all_items' => _x( 'All Publication Categories', 'Publication Categories' ), 'parent_item' => _x( 'Parent Publication Categories', 'Publication Categories' ), 'parent_item_colon' => _x( 'Parent Publication Categories:', 'Publication Categories' ), 'edit_item' => _x( 'Edit Publication Category', 'Publication Categories' ), 'update_item' => _x( 'Update Publication Category', 'Publication Categories' ), 'add_new_item' => _x( 'Add New Publication Category', 'Publication Categories' ), 'new_item_name' => _x( 'New Publication Category', 'Publication Categories' ), 'separate_items_with_commas' => _x( 'Separate Publication Categories with commas', 'Publication Categories' ), 'add_or_remove_items' => _x( 'Add or remove Publication Category', 'Publication Categories' ), 'choose_from_most_used' => _x( 'Choose from the most used Publication Categories', 'Publication Categories' ), 'menu_name' => _x( 'Publication Categories', 'Publication Categories' ), ); $args = array( 'labels' => $labels, 'public' => true, 'show_in_nav_menus' => false, 'show_ui' => true, 'show_tagcloud' => true, 'show_admin_column' => true, 'hierarchical' => true, 'rewrite' => true, 'query_var' => true ); register_taxonomy( 'Publication Categories', array('publication'), $args );}//-----------------------NEWS Custom post type-----------------------------------------------------add_action( 'init', 'register_cpt_news' );function register_cpt_news() { $labels = array( 'name' => _x( 'News', 'publication' ), 'singular_name' => _x( 'News', 'publication' ), 'add_new' => _x( 'Add New', 'News' ), 'add_new_item' => _x( 'Add New News', 'publication' ), 'edit_item' => _x( 'Edit News', 'publication' ), 'new_item' => _x( 'New News', 'publication' ), 'view_item' => _x( 'View News', 'publication' ), 'search_items' => _x( 'Search News', 'publication' ), 'not_found' => _x( 'No News found', 'publication' ), 'not_found_in_trash' => _x( 'No News found in Trash', 'publication' ), 'parent_item_colon' => _x( 'Parent News:', 'publication' ), 'menu_name' => _x( 'News', 'publication' ), ); $args = array( 'labels' => $labels, 'hierarchical' => false, 'supports' => array( 'title', 'editor', 'excerpt', 'author', 'thumbnail', 'trackbacks', 'custom-fields', 'comments', 'revisions', 'page-attributes' ), 'taxonomies' => array( 'news_category' ), 'public' => true, 'show_ui' => true, 'show_in_menu' => true, 'menu_position' => 5, 'show_in_nav_menus' => false, 'publicly_queryable' => true, 'exclude_from_search' => false, 'has_archive' => true, 'query_var' => true, 'can_export' => true, 'rewrite' => true, 'capability_type' => 'post' ); register_post_type( 'News', $args );}add_action( 'init', 'register_taxonomy_newscategories' );function register_taxonomy_newscategories() { $labels = array( 'name' => _x( 'News Categories', 'newscategories' ), 'singular_name' => _x( 'News Category', 'newscategories' ), 'search_items' => _x( 'Search News Categories', 'newscategories' ), 'popular_items' => _x( 'Popular News Categories', 'newscategories' ), 'all_items' => _x( 'All News Categories', 'newscategories' ), 'parent_item' => _x( 'Parent News Category', 'newscategories' ), 'parent_item_colon' => _x( 'Parent News Category:', 'newscategories' ), 'edit_item' => _x( 'Edit News Category', 'newscategories' ), 'update_item' => _x( 'Update News Category', 'newscategories' ), 'add_new_item' => _x( 'Add New News Category', 'newscategories' ), 'new_item_name' => _x( 'New News Category', 'newscategories' ), 'separate_items_with_commas' => _x( 'Separate News Categories with commas', 'newscategories' ), 'add_or_remove_items' => _x( 'Add or remove News Categories', 'newscategories' ), 'choose_from_most_used' => _x( 'Choose from the most used News Categories', 'newscategories' ), 'menu_name' => _x( 'News Categories', 'newscategories' ), ); $args = array( 'labels' => $labels, 'public' => true, 'show_in_nav_menus' => false, 'show_ui' => true, 'show_tagcloud' => true, 'show_admin_column' => true, 'hierarchical' => true, 'rewrite' => true, 'query_var' => true ); register_taxonomy( 'newscategories', array('news'), $args );}?> نقل قول لینک به ارسال
Mostafa 2587 ارسال شده در خرداد 93 گزارش بازنشر ارسال شده در خرداد 93 سلام،1- فایل single-publication.php رو ایجاد کردم و نوشته های تکی publication رو توش بدون مشکل نشون میدم ولی با نمایش دسته بندی های نوشته ها مشکل دارمبرای قالب دسته بندی ها بهتره از فایل با نام taxonomy-{taxonomy}.php بسازید.2- فایلی که مثل صفحه ی index یا home بتونم لیست پست های سفارشی رو توش قرار بدم چطوریه ؟ آیا باید از template سفارشی استفاده کنم یا راه بهتری داره ؟میتونید یک Custom page بسازید و یک کوئری درونش ایجاد کنید که پست های سفارشی رو نشون بده.3- برای دسته بندی های Publication Categories و newscategories چطور صفحه ای مثل category.php درست کنم که باکلیک روی یک دسته بندی سفارشی لیست نوشته های اون دسته بندی رو نمایش بدم ؟برای دسته بندی میتونید از taxonomy-{taxonomy}.php و برای بایگانی نیز میتوانید از archive-{post_type}.php استفاده نمائید.4- کلاً چطور می تونم هر چیزی رو که برای نوشته ها و دسته بندی های معمولی وجود داره رو برای نوشته و دسته بندی های سفارشی ام داشته باشم ؟در موارد بالا خدمتتان عرض شد.اگر موارد بالا کار نکرد، پیوندیکتا یا مقادیر rewrite را در پارامترهای سورس کُدتان تغییر دهید. 3 نقل قول لینک به ارسال
پست های پیشنهاد شده
به گفتگو بپیوندید
هم اکنون می توانید مطلب خود را ارسال نمایید و بعداً ثبت نام کنید. اگر حساب کاربری دارید، برای ارسال با حساب کاربری خود اکنون وارد شوید .