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

arta.mo

تازه وارد
سلام

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

این هم کد هایی که توی قالب در زمینه با بخش نمونه کارها وجود داره

فایل single-portfolio.php

<?php get_header();?> <!-- **Content** --> <div class="content content-full-width"> <?php if( have_posts() ): ?> <?php while ( have_posts() ) : the_post(); ?> <?php get_template_part( 'framework/loops/content', 'single-portfolio' ); ?> <?php endwhile; endif;?> <!-- Releated Gallery Section --> <?php $portfolio_settings = get_post_meta($post->ID,'_portfolio_settings',TRUE); $portfolio_settings = is_array($portfolio_settings) ? $portfolio_settings : array(); if(array_key_exists("show-releated-items",$portfolio_settings)): $category_ids = array(); $input = wp_get_object_terms( $post->ID, 'portfolio_entries'); foreach($input as $category) $category_ids[] = $category->term_id; $args = array('orderby' => 'rand','showposts' => 3 ,'post__not_in' => array($post->ID), 'tax_query' => array( array( 'taxonomy'=>'portfolio_entries', 'field'=>'id', 'operator'=>'IN', 'terms'=>$category_ids ))); query_posts($args); if( have_posts() ):?> <h2><?php _e('Related Projects','ultimate');?></h2> <!-- **Portfolio** --> <div class="portfolio column-one-third"> <?php $count = 1; while(have_posts()): the_post(); $the_id = get_the_ID(); $title = $title = ( strlen(get_the_title()) > 28 ) ? substr(get_the_title(),0,26)."..." :get_the_title() ; $permalink = get_permalink(); $class = ($count%3== 0) ? ' last': '';?> <div class="column one-third <?php echo $class;?>"> <div class="thumb"> <a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( '%s'), the_title_attribute( 'echo=0' ) ); ?>"> <?php if(has_post_thumbnail()): the_post_thumbnail('portfolio-three-column'); else: ?> <img src="<?php echo IAMD_BASE_URL."images/dummy-images/portfolio-three-column.jpg";?>" alt="" /> <?php endif; ?> </a> <div class="image-overlay"> <?php $full = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'full', false); $portfolio_settings = get_post_meta($post->ID,'_portfolio_settings',TRUE); $portfolio_settings = is_array($portfolio_settings) ? $portfolio_settings : array(); if(array_key_exists("video_url",$portfolio_settings)):?> <a href="<?php echo $portfolio_settings['video_url'];?>" target="_blank" data-gal="prettyPhoto[gallery]" class="image-overlay-video"></a> <?php elseif($full): ?> <a href="<?php echo $full[0];?>" data-gal="prettyPhoto[gallery]" class="image-overlay-zoom"></a> <?php else: ?> <a href="<?php echo IAMD_BASE_URL."images/dummy-images/portfolio-three-column.jpg";?>" data-gal="prettyPhoto[gallery]" class="image-overlay-zoom"></a> <?php endif;?> <?php if(array_key_exists("url",$portfolio_settings)): ?> <a href="<?php echo $portfolio_settings["url"];?>" target="_blank" class="image-overlay-link"> </a> <?php else: ?> <a href="<?php the_permalink();?>" title="<?php printf( esc_attr__('%s'), the_title_attribute('echo=0'));?>" class="image-overlay-link"> </a> <?php endif;?> </div><!-- .image-overlay end --> </div><!-- .thumb --> <h4><a href="<?php the_permalink();?>" title="<?php the_title();?>"><?php the_title();?></a></h4> <div class="buttons"> <a href="<?php echo $permalink; ?>" title="<?php printf( esc_attr__( '%s'), the_title_attribute( 'echo=0' ) );?>" class="button small light-grey"><span><?php _e('View Project','ultimate');?></span></a> <?php $portfolio_settings = get_post_meta($post->ID,'_portfolio_settings',TRUE); $portfolio_settings = is_array($portfolio_settings) ? $portfolio_settings : array(); if(array_key_exists("url",$portfolio_settings)):?> <a href="<?php echo $portfolio_settings["url"];?>" title="" class="button small light-grey" target="_blank"> <span><?php _e('Go to site','ultimate');?></span></a> <?php endif;?> </div><!-- .buttons end --> </div><!-- .column end--> <?php $count++; endwhile; ?> </div><!-- .column-one-third **Portfolio - End** --> <?php endif;?> <?php endif;?> <!-- Releated Gallery Section End --> </div><!-- **Portfolio Single - End** --> <!-- Open div is in content-single-portfolio.php --> </div> <!-- **Content - End** --><?php get_footer();?>و فایل tpl-portfolio.php

<?php /*Template Name: Portfolio Template*/?><?php get_header();?><?php $tpl_portfolio_settings = get_post_meta($post->ID,'_tpl_portfolio_settings',TRUE); $tpl_portfolio_settings = is_array($tpl_portfolio_settings) ? $tpl_portfolio_settings : array(); $sortable = isset($tpl_portfolio_settings['filter'])?'sortable':NULL; $page_layout = ""; $post_layout = ""; $post_class = ""; $image_type = ""; $show_sidebar = false; $sidebar_class=""; $categories = ""; $categories = isset($tpl_portfolio_settings['cats']) ? array_filter($tpl_portfolio_settings['cats']) : $categories; if(empty($categories)): $categories = get_categories('taxonomy=portfolio_entries&hide_empty=1'); else: $args = array('taxonomy'=>'portfolio_entries','hide_empty'=>1,'include'=>$categories); $categories = get_categories($args); endif; switch($tpl_portfolio_settings['page-layout']): case 'content-full-width': $page_layout = "content-full-width"; break; case 'with-left-sidebar': $page_layout = "with-left-sidebar"; $show_sidebar = true; $sidebar_class = "left-sidebar"; break; case 'with-right-sidebar': $show_sidebar = true; break; default: $page_layout = "content-full-width"; break; endswitch; switch($tpl_portfolio_settings['post-layout']): case 'one-column': $post_layout = $show_sidebar ? "one-column-with-sidebar" : "one-column"; $post_class = "column"; $image_type = $show_sidebar ? "portfolio-one-column-with-sidebar" : "portfolio-one-column"; break; case 'one-half-column': $post_layout = $show_sidebar ? "column-one-half-with-sidebar" : "column-one-half"; $post_class = "one-half"; $image_type = $show_sidebar ? "portfolio-two-column-with-sidebar" : "portfolio-two-column"; break; case 'one-third-column': $post_layout = $show_sidebar ? "column-one-third-with-sidebar" : "column-one-third"; $post_class = "one-third"; $image_type = $show_sidebar ? "portfolio-three-column-with-sidebar" : "portfolio-three-column"; break; endswitch;?> <!-- **Content** --> <div class="content <?php echo $page_layout;?>"> <?php if($show_sidebar):?> <div class="inner-with-sidebar"></div> <?php endif;?> <?php if( have_posts() ): ?> <?php while ( have_posts() ) : the_post(); ?> <?php get_template_part( 'framework/loops/content', 'portfolio-page' ); ?> <?php endwhile; endif; ?> <!--- Portfolio item content --> <div class="portfolio <?php echo $post_layout;?>"> <?php if( array_key_exists("filter",$tpl_portfolio_settings) && (!empty($categories)) ): ?> <div id="sorting-container"> <a href="#" class="active_sort" title="" data-filter=".all-sort"><?php _e('All','ultimate');?></a> <?php foreach( $categories as $category ): ?> <a href='#' data-filter=".<?php echo $category->category_nicename;?>-sort"><?php echo $category->cat_name;?></a> <?php endforeach; ?> </div> <?php endif; ?> <!-- **Portfolio Container** --> <div class="portfolio-container gallery"> <?php $args = array(); $categories = array_filter($tpl_portfolio_settings['cats']); if(is_array($categories) && !empty($categories)): $terms = $categories; $args = array( 'orderby' => 'ID' ,'order' => 'ASC' ,'paged' => get_query_var( 'paged' ) ,'posts_per_page' => $tpl_portfolio_settings['post-per-page'] ,'tax_query' => array( array( 'taxonomy'=>'portfolio_entries', 'field'=>'id', 'operator'=>'IN', 'terms'=>$terms ) ) ); else: $args = array( 'paged' => get_query_var( 'paged' ) ,'posts_per_page' => $tpl_portfolio_settings['post-per-page'] ,'post_type' => 'portfolio'); endif; query_posts($args); if( have_posts() ): while( have_posts() ): the_post(); $the_id = get_the_ID(); #Find sort class by using the portfolio_entries $sort = ""; $item_categories = get_the_terms( $the_id, 'portfolio_entries' ); if(is_object($item_categories) || is_array($item_categories)): foreach ($item_categories as $category): $sort .= $category->slug.'-sort '; endforeach; endif;?> <div class="post-entry <?php echo $post_class;?> column all-sort <?php echo $sort;?>"> <div class="thumb"> <a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( '%s'), the_title_attribute( 'echo=0' ) ); ?>"> <?php if(has_post_thumbnail()): the_post_thumbnail($image_type); else: ?> <img src="<?php echo IAMD_BASE_URL."images/dummy-images/{$image_type}.jpg";?>" alt="" /> <?php endif; ?> </a> <div class="image-overlay"> <?php $full = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'full', false); $portfolio_settings = get_post_meta($post->ID,'_portfolio_settings',TRUE); $portfolio_settings = is_array($portfolio_settings) ? $portfolio_settings : array(); if(array_key_exists("video_url",$portfolio_settings)):?> <a href="<?php echo $portfolio_settings['video_url'];?>" target="_blank" data-gal="prettyPhoto[gallery]" class="image-overlay-video"> </a> <?php elseif($full): ?> <a href="<?php echo $full[0];?>" data-gal="prettyPhoto[gallery]" class="image-overlay-zoom"> </a> <?php else: ?> <a href="<?php echo IAMD_BASE_URL."images/dummy-images/{$image_type}.jpg";?>" data-gal="prettyPhoto[gallery]" class="image-overlay-zoom"> </a> <?php endif;?> <?php if(array_key_exists("url",$portfolio_settings)): ?> <a href="<?php echo $portfolio_settings["url"];?>" target="_blank" class="image-overlay-link"> </a> <?php else: ?> <a href="<?php the_permalink();?>" title="<?php printf( esc_attr__('%s'), the_title_attribute('echo=0'));?>" class="image-overlay-link"> </a> <?php endif;?> </div> </div> <h4><a href="<?php the_permalink();?>" title="<?php the_title();?>"><?php the_title();?></a></h4> <?php if( array_key_exists("excerpt",$tpl_portfolio_settings)):?> <div class="portfolio-desc"><?php echo mytheme_excerpt($tpl_portfolio_settings['excerpt-length']);?></div> <?php endif;?> <div class="buttons"> <a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( '%s'), the_title_attribute( 'echo=0' ) ); ?>" class="button small light-grey"> <span><?php _e('View Project','ultimate');?></span></a> <?php $portfolio_settings = get_post_meta($post->ID,'_portfolio_settings',TRUE); $portfolio_settings = is_array($portfolio_settings) ? $portfolio_settings : array(); if(array_key_exists("url",$portfolio_settings)):?> <a href="<?php echo $portfolio_settings["url"];?>" title="" class="button small light-grey" target="_blank"> <span><?php _e('Go to site','ultimate');?></span></a> <?php endif;?> </div> </div> <?php endwhile; endif;?> </div><!-- **Portfolio Container - End** --> <!-- **Pagination** --> <div class="pagination"> <?php previous_posts_link('<span class="prev-post"></span>');?> <?php echo my_pagination();?> <?php next_posts_link('<span class="next-post"></span>');?> </div><!-- **Pagination - End** --> </div><!--- Portfolio item content end--> </div> <!-- **Content - End** --> <?php if($show_sidebar): ?> <!-- **Sidebar** --> <div class="sidebar <?php echo $sidebar_class;?>"> <div class="inner-sidebar"> </div> <?php get_sidebar();?> </div><!-- **Sidebar - End** --> <?php endif; ?> <?php get_footer();?>البته من این دوتا رو کپی کردم و یه سری توابعش رو هم تغییر دادم تا دو تا بخش نمونه کار توی بخش مدیریت وردپرس ظاهر بشه و توی یک بخشش محصولات رو بزارم ولی موفق نشدم

اساتید کمک کنید لطفا

 

Qalekhani

قلعه‌خانی
سلام. لطفا در خصوص "افزودن post type" در همین انجمن جستجو کنید. روشش رو دوستان توضیح دادند

 

arta.mo

تازه وارد
توی انجمن که چیزی پیدا نکردم ولی در مورد این پست تایپ که فرمودین این مطالب رو پیدا کردم

1- افزودن کد به function.php

function my_custom_post_product() { $args = array(); register_post_type( 'product', $args ); }add_action( 'init', 'my_custom_post_product' );و کد های

function my_custom_post_product() {$labels = array('name' => _x( 'محصولات', 'post type general name' ),'singular_name' => _x( 'محصول', 'post type singular name' ),'add_new' => _x( 'افزودن جدید', 'book' ),'add_new_item' => __( 'افزودن محصول جدید' ),'edit_item' => __( 'ویرایش محصول' ),'new_item' => __( 'محصول جدید' ),'all_items' => __( 'همه محصولات' ),'view_item' => __( 'نمایش محصول' ),'search_items' => __( 'جست و جو محصول' ),'not_found' => __( 'محصولی یافت نشد' ),'not_found_in_trash' => __( 'محصولی در زباله دان یافت نشد' ),'parent_item_colon' => '','menu_name' => 'محصولات');$args = array('labels' => $labels,'description' => 'ذخیره اطلاعات مربوط به محصولات','public' => true,'menu_position' => 5,'supports' => array( 'title', 'editor', 'thumbnail', 'excerpt', 'comments' ),'has_archive' => true,);register_post_type( 'product', $args );}add_action( 'init', 'my_custom_post_product' );و

unction my_taxonomies_product() { $labels = array( 'name' => _x( 'دسته بندی محصولات', 'taxonomy general name' ), 'singular_name' => _x( 'دسته بندی محصولات', 'taxonomy singular name' ), 'search_items' => __( 'جست و جوی دسته بندی محصولات' ), 'all_items' => __( 'همه دسته بندی محصولات' ), 'parent_item' => __( 'دسته بندی محصول جاری' ), 'parent_item_colon' => __( 'دسته بندی محصول جاری:' ), 'edit_item' => __( 'ویرایش دسته بندی محصول' ), 'update_item' => __( 'تغییر دسته بندی محصول' ), 'add_new_item' => __( 'افزودن دسته بندی جدید محصول' ), 'new_item_name' => __( 'دسته بندی جدید محصول' ), 'menu_name' => __( 'دسته بندی محصولات' ), ); $args = array( 'labels' => $labels, 'hierarchical' => true, ); register_taxonomy( 'product_category', 'product', $args );}add_action( 'init', 'my_taxonomies_product', 0 );ولی من همه ی این کد ها رو توی فایل fanction.php  گذاشتم و بازم جواب نگرفتم یعنی چیزی توی بخش مدیریت نیومد که هیچ به هم ریخت همه چیز

اینم محتویات اولیه فایل فانکشن قالب

<?php if( ! defined('IAMD_BASE_URL' ) ){ define( 'IAMD_BASE_URL', get_template_directory_uri().'/'); }define('IAMD_FW_URL', IAMD_BASE_URL . 'framework/' );define('IAMD_FW',TEMPLATEPATH.'/framework/');define('IAMD_IMPORTER_URL',IAMD_FW.'wordpress-importer/');define('IAMD_THEME_SETTINGS', 'mytheme');define('IAMD_SAMPLE_FONT',__('Sample Font','ultimate'));/* Define IAMD_THEME_NAME * Objective: * Used to show theme name where ever needed( eg: in widgets title ar the back-end). */// get themedata version wp 3.4+if(function_exists('wp_get_theme')): $theme_data = wp_get_theme(); define('IAMD_THEME_NAME',$theme_data->get('Name')); define('IAMD_THEME_FOLDER_NAME',$theme_data->template); define('IAMD_THEME_VERSION',(float) $theme_data->get('Version'));endif;#ALL BACKEND DETAILS WILL BE IN include.phprequire_once(TEMPLATEPATH.'/framework/include.php');require_once(TEMPLATEPATH.'/framework/theme_woocommerce.php');if ( ! isset( $content_width ) ) $content_width = 675; ?>لطفا کمک کنید چی رو کجا بزارم دقیقا تا این بخش محصولات ظاهر بشه

 

Qalekhani

قلعه‌خانی
یه بررسی از این افزونه ها بکنید، ببینید نیازتون رو برطرف میکنه





 

arta.mo

تازه وارد
نه که این دو تا

 از دیروز هزارو یک افزونه تست کردم ولی عین واقعیت اونطوری که من می خوام نیستن و در برخی موارد هم حجمشون بالاس و سایت رو کند می کنن

کاش در مورد هکش یخورده راهنمایی می کردین :46:

 

arta.mo

تازه وارد
<?php /// function.php function product_post_type() { $labels = array( 'name' => _x( 'محصولات', 'Post Type General Name', 'text_domain' ), 'singular_name' => _x( 'محصول', 'Post Type Singular Name', 'text_domain' ), 'menu_name' => __( 'محصولات', 'text_domain' ), 'parent_item_colon' => __( 'Parent Item:', 'text_domain' ), 'all_items' => __( 'تمام محصولات', 'text_domain' ), 'view_item' => __( 'نمایش محصول', 'text_domain' ), 'add_new_item' => __( 'افزودن محصول', 'text_domain' ), 'add_new' => __( 'محصول جدید', 'text_domain' ), 'edit_item' => __( 'ویرایش محصول', 'text_domain' ), 'update_item' => __( 'بروزرسانی محصول', 'text_domain' ), 'search_items' => __( 'جستجوی محصول', 'text_domain' ), 'not_found' => __( 'یافت نشد', 'text_domain' ), 'not_found_in_trash' => __( 'یافت نشد', 'text_domain' ), ); $args = array( 'label' => __( 'product', 'text_domain' ), 'description' => __( 'محصولات همکاری در فروش', 'text_domain' ), 'labels' => $labels, 'supports' => array( 'title', 'editor', 'thumbnail', 'custom-fields', ), 'taxonomies' => array( 'category', 'post_tag' ), 'hierarchical' => true, 'public' => true, 'show_ui' => true, 'show_in_menu' => true, 'single' => true, 'show_in_nav_menus' => true, 'show_in_admin_bar' => true, 'menu_position' => 5, 'menu_icon' => 'dashicons-admin-post', 'can_export' => true, 'has_archive' => true, 'exclude_from_search' => false, 'publicly_queryable' => true, 'capability_type' => 'page', ); register_post_type( 'product', $args ); } add_action( 'init', 'product_post_type', 0 ); /// function for display product post typeadd_filter( 'pre_get_posts', 'my_get_posts' ); function my_get_posts( $query ) { if ( is_home() && $query->is_main_query() ) $query->set( 'post_type', array( 'post', 'product' ) ); return $query;}?>کد بالا رو توی فانکشن پی اچ پی گذاشتم و بخش محصولات به قسمت مدیریت اضافه شد

ولی توی سایت نات فوند میزنه ، مشکل چیه

 
بالا