Temanızın içinde inc klasörünün içindeki custom-functions.php'yi açıp aşağıdakiler ile değiştirin.
<?php
/* Adds the Product post type */
$products = new Cuztom_Post_Type( 'Urunler', array(
'has_archive' => true,
'supports' => array( 'title', 'editor', 'thumbnail' )
) );
/* Adds metaboxes to products */
$products->add_meta_box(
'Product info',
array(
array(
'name' => 'product_link',
'label' => 'Product url',
'description' => 'Link to product',
'type' => 'text',
),
array(
'name' => 'product_description',
'label' => 'Product description',
'description' => 'One line description of product',
'type' => 'textarea',
),
array(
'name' => 'product_price',
'label' => 'Product price',
'description' => 'Price of the product',
'type' => 'text',
)
));
function add_custom_taxonomies() {
register_taxonomy('bolum', 'products', array(
// Hierarchical taxonomy (like categories)
'hierarchical' => true,
// This array of options controls the labels displayed in the WordPress Admin UI
'labels' => array(
'name' => _x( 'Department', 'taxonomy general name' ),
'singular_name' => _x( 'Department', 'taxonomy singular name' ),
'search_items' => __( 'Search Department' ),
'all_items' => __( 'All Department' ),
'parent_item' => __( 'Parent Department' ),
'parent_item_colon' => __( 'Parent Department:' ),
'edit_item' => __( 'Edit Department' ),
'update_item' => __( 'Update Department' ),
'add_new_item' => __( 'Add New Department' ),
'new_item_name' => __( 'New Department Name' ),
'menu_name' => __( 'Department' ),
),
// Control the slugs used for this taxonomy
'rewrite' => array(
'slug' => 'department', // This controls the base slug that will display before each term
'with_front' => false, // Don't display the category base before "/locations/"
'hierarchical' => true // This will allow URL's like "/locations/boston/cambridge/"
),
));
}
add_action( 'init', 'add_custom_taxonomies', 0 );Temanın içindeki products.php'yi açıp aşağıdakiler ile değiştirin.
<?php
/**
Template name: Shop
* The main template file.
*
* This is the most generic template file in a WordPress theme
* and one of the two required files for a theme (the other being style.css).
* It is used to display a page when nothing more specific matches a query.
* E.g., it puts together the home page when no home.php file exists.
* Learn more: http://codex.wordpress.org/Template_Hierarchy
*
* @package web2feel
* @since web2feel 1.0
*/
get_header(); ?>
<div id="primary" class="content-area cf">
<div id="content" class="site-content" role="main">
<div class="article-list cf">
<?php
if ( get_query_var('paged') )
$paged = get_query_var('paged');
elseif ( get_query_var('page') )
$paged = get_query_var('page');
else
$paged = 1;
$wp_query = new WP_Query(array('post_type' => 'products', 'posts_per_page' => '4', 'paged' => $paged ));
?>
<?php while ($wp_query->have_posts()) : $wp_query->the_post(); ?>
<div class="product-box grid_3">
<div class="prod-thumb">
<?php
$thumb = get_post_thumbnail_id();
$img_url = wp_get_attachment_url( $thumb,'full' ); //get full URL to image (use "large" or "medium" if the images too big)
$image = aq_resize( $img_url, 180, 150, false ); //resize & crop the image
?>
<?php if($image) : ?> <a href="<?php the_permalink(); ?>"><img src="<?php echo $image ?>"/></a> <?php endif; ?>
</div>
<div class="prod-info">
<div class="pricebar cf">
<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<span class="pricetag"><?php echo get_post_meta($post->ID,'_product_info_product_price', true); ?> </span>
</div>
<p> <?php echo get_post_meta($post->ID,'_product_info_product_description', true); ?> </p>
<div class="prod-footer cf">
<span class="pleft"> <a href="<?php the_permalink(); ?>">View details</a> </span>
<span class="pright"><a href="<?php echo get_post_meta($post->ID,'_product_info_product_link', true); ?>">Buy Now</a> </span>
</div>
</div>
</div>
<?php endwhile; ?>
</div>
<?php //web2feel_content_nav( 'nav-below' ); ?>
<div class="grid_12">
<?php kriesi_pagination("$wp_query->max_num_pages"); ?>
</div>
</div><!-- #content .site-content -->
</div><!-- #primary .content-area -->
<?php get_footer(); ?>Tekrar tema klasörünün içindeki taxonomy-department.php dosyasını açıp aşağıdaki kodlar ile değiştirin. Sorunun çözülmesi gerekiyor.
<?php
/**
* The template for displaying Archive pages.
*
* Learn more: http://codex.wordpress.org/Template_Hierarchy
*
* @package web2feel
* @since web2feel 1.0
*/
get_header(); ?>
<section id="primary" class="content-area cf">
<div id="content" class="site-content" role="main">
<?php if ( have_posts() ) : ?>
<header class="page-header grid_12">
<h1 class="page-title">
<?php echo get_the_term_list( $post->ID, 'bolum', 'Department: ', ', ', '' ); ?> </h1>
</header><!-- .page-header -->
<div class="article-list cf">
<?php /* Start the Loop */ ?>
<?php while ( have_posts() ) : the_post(); ?>
<div class="product-box grid_3">
<div class="prod-thumb">
<?php
$thumb = get_post_thumbnail_id();
$img_url = wp_get_attachment_url( $thumb,'full' ); //get full URL to image (use "large" or "medium" if the images too big)
$image = aq_resize( $img_url, 180, 150, false ); //resize & crop the image
?>
<?php if($image) : ?> <a href="<?php the_permalink(); ?>"><img src="<?php echo $image ?>"/></a> <?php endif; ?>
</div>
<div class="prod-info">
<div class="pricebar cf">
<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<span class="pricetag"><?php echo get_post_meta($post->ID,'_product_info_product_price', true); ?> </span>
</div>
<p> <?php echo get_post_meta($post->ID,'_product_info_product_description', true); ?> </p>
<div class="prod-footer cf">
<span class="pleft"> <a href="<?php the_permalink(); ?>">View details</a> </span>
<span class="pright"><a href="<?php echo get_post_meta($post->ID,'_product_info_product_link', true); ?>">Buy Now</a> </span>
</div>
</div>
</div>
<?php endwhile; ?>
</div>
<?php kriesi_pagination(); ?>
<?php else : ?>
<?php get_template_part( 'no-results', 'archive' ); ?>
<?php endif; ?>
</div><!-- #content .site-content -->
</section><!-- #primary .content-area -->
<?php get_footer(); ?>