카테고리를 표시하기 위해 필터를 사용하는 포트폴리오가있는 테마가 있습니다 (ALL, NEW, OLD). 그러나,로드 할 때 특정 ("새") 카테고리가 표시된 유일한 카테고리가되기를 바랍니다. 사용자가 과거의 제품을보고하고자하는 경우WordPress : 필터를 사용하여로드 할 때 특정 카테고리 표시
그런 다음, 그들은 클릭 것 등등 "OLD"와 ..
내가 다른 포트폴리오를 만들 것 명심하십시오, 그 포트폴리오의 새로운 항목에서만 표시되는 처음에로드하십시오.
몇 시간 동안 답변을 찾으려고했지만 아직 찾을 수 없습니다.
<?php
/**
* Taxonomy Template for the Portfolios
*/
?>
<?php get_header(); ?>
<?php
if ($post) :
$port = wp_get_post_terms($post->ID, array('portfolios'));
$portfolio = $port[0];
$post_img_width = "";
$post_img_height = "";
global $mav_data; // fetch options stored in $mav_data
$portfolio_order_1 = $mav_data['portfolio_order_1']; // date, title
$portfolio_order_2 = $mav_data['portfolio_order_2']; // ASC, DESC
$tax_query[] = array(
//'taxonomy' => $wp_query->query_vars['taxonomy'],
'taxonomy' => 'portfolios',
'field' => 'slug',
'terms' => array($portfolio->slug)
);
$args = array(
'post_type'=> 'project',
'posts_per_page'=> -1,
'orderby' => $portfolio_order_1,
'order' => $portfolio_order_2,
'tax_query' => $tax_query
);
$port_query = new WP_Query($args);
?>
<?php
$tag_extra_fields = get_option('portfolios_fields');
$portfolio_layout = $tag_extra_fields[$portfolio->term_id]['_portfolio_layout'];
?>
<section id="content" class="portfolio one-column <?php echo esc_attr($portfolio_layout); ?>" role="main">
<div class="wrapper clearfix">
<header class="page-header">
<h1 class="entry-title"><?php echo($portfolio->name); ?></h1>
<?php if ($portfolio->description) { ?><p class="portfolio-header-description"><?php echo($portfolio->description); ?></p><?php } ?>
<?php
$temp = array();
foreach ($posts as $post) {
$temp_args = array();
while ($port_query->have_posts()) : $port_query->the_post(); // the loop begins, we need it here. It's important!!
$temp_cats = wp_get_object_terms($post->ID, 'project_category'/*, $args*/);
if ($temp_cats) {
foreach ($temp_cats as $temp_cat) {
if (! in_array($temp_cat->slug, $temp)) {
$temp[] = $temp_cat->slug;
$categories[] = $temp_cat;
}
}
}
endwhile;
}
// DAHEX
$temp = array();
if(!empty($categories)) {
foreach ($categories as $category) {
$temp[] = array ('term_id'=>$category->term_id,'name'=>$category->name,'slug'=>$category->slug,'term_group'=>$category->term_group,'term_taxonomy_id'=>$category->term_taxonomy_id,'taxonomy'=>$category->taxonomy,'description'=> $category->description,'parent'=>$category->parent,'count'=> $category->count);
}
}
usort($temp, array(new Sorter('slug'), 'sort')); // Sorting Array by slug
$categories = array();
foreach ($temp as $category){
$categories[] =(object) $category;
}
// DAHEX
if(!empty($categories)) {
if(!is_wp_error($categories)){
echo('<ul id="filters" class="option-set">
<li><a href="#" data-filter="*" class="show-all selected">All</a></li>');
foreach ($categories as $category) {
echo '<li><span class="sep">/</span><a href="#' . $category->slug . '" data-filter=".' . $category->slug . '">' . $category->name . '</a></li>';
}
echo('</ul> <!-- /end #filters -->');
} else {
echo '<span class="ooops">';
_e('Ooops! nothing found...', 'mav_framework');
echo '</span>';
}
}
?>
</header> <!-- /end .page-header -->
<section id="projects">
<?php
while ($port_query->have_posts()) : $port_query->the_post(); // the loop begins
$terms = get_the_terms(get_the_ID(), 'project_category');
$terms = $terms == false ? array() : $terms;
?>
<?php
$custom = get_post_custom($post->ID);
$portfolio_permalink = $custom["project_permalink"][0];
$portfolio_desc = $custom["project_desc"][0];
if (!isset($lightbox_path)) {
$lightbox_path = '';
}
// Prepare Project Image Thumb
$project_img = $custom["project_img"][0];
$project_img_ID = $custom['project_img_ID'][0];
// Need some proof check to ensure that no "notice" is thrown ...
if (! empty($portfolio)) {
$term_slug = $portfolio->slug;
if (isset($custom["lightbox_path"][0])) {
$lightbox_path = $custom["lightbox_path"][0];
} else {
$lightbox_path = '';
}
$empty_thumb = '<img class="portfolios_single_thumb portfolio-image" src="' . get_template_directory_uri() . '/images/thumb.png" width="' . $post_img_width . '" height="' . $post_img_height . '" alt="' . $post->post_title . '" />';
if (isset($project_img_ID)) {
if (is_numeric($project_img_ID)) {
$thumb_ID = $project_img_ID;
$thumb = wp_get_attachment_image($thumb_ID, 'mav-thumbnails', false, array('class' => 'portfolios_post_image_thumb portfolio-image', 'alt' => $post->post_title));
if (empty ($thumb)) {
$thumb = $empty_thumb;
}
} elseif($project_img_ID != "") {
$thumb = '<div class="project_iframe_thumb-$term_slug"><iframe width="' . $post_img_width . '" height="' . $post_img_height . '" src="' . $project_img . '" title="' . $project_img_ID . '" frameborder="0" allowfullscreen></iframe></div>';
} else {
$thumb = $empty_thumb;
}
} else {
$thumb = $empty_thumb;
}
}
?>
<article id="project-<?php the_ID(); ?>" class="element <?php foreach ($terms as $term) { echo strtolower(preg_replace('/\s+/', '-', $term->slug)). ' '; } ?>">
<?php
/**
* Generate the Project Image (Thumb)
*/
if ($lightbox_path != '') { ?>
<figure class="thumb-container">
<a href="<?php echo esc_attr($lightbox_path); ?>" data-rel="prettyPhoto" title="<?php the_title_attribute(); ?>">
<span class="overlay lightbox"></span>
<?php mav_framework_project_label($post, array('portfolios-project-label')); ?>
<?php echo($thumb); ?>
</a>
</figure> <!-- /end .thumb-container -->
<?php
} elseif ($portfolio_permalink) {
?>
<figure class="thumb-container">
<a target="_blank" href="<?php echo esc_attr($portfolio_permalink); ?>" rel="bookmark">
<span class="overlay link"></span>
<?php mav_framework_project_label($post, array('portfolios-project-label')); ?>
<?php echo($thumb); ?>
</a>
</figure> <!-- /end .thumb-container -->
<?php } else { ?>
<figure class="thumb-container">
<a href="<?php the_permalink() ?>" rel="bookmark">
<span class="overlay">
<span class="view"><?php _e('View', 'mav_framework'); ?></span>
</span>
<?php mav_framework_project_label($post, array('portfolios-project-label')); ?>
<?php echo($thumb); ?>
</a>
</figure> <!-- /end .thumb-container -->
<?php } // end Generate the Project Image (Thumb) ?>
<h2 class="project-title">
<?php if ($portfolio_permalink) { ?>
<a target="_blank" href="<?php echo esc_url($portfolio_permalink); ?>" rel="bookmark"><?php the_title(); ?></a>
<?php } else { ?>
<a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a>
<?php } ?>
</h2>
<?php if ($portfolio_desc) { ?><p class="project-description"><?php echo do_shortcode(stripslashes($portfolio_desc)); ?></p><?php } ?>
<footer class="entry-meta">
<span class="posted-on">
<?php _e('<span class="posted-on-title">Posted on: </span>', 'mav_framework'); ?><a href="<?php the_permalink() ?>"><?php /* http://codex.wordpress.org/Formatting_Date_and_Time */ echo get_the_date('F j, Y'); ?></a>
</span> <!-- /end .posted-on -->
<?php
$project_categories = wp_get_object_terms($post->ID, 'project_category');
if ($project_categories) { ?>
<span class="cat-links">
<?php
_e('<span class="cat-links-title">Category: </span>', 'mav_framework');
$project_category = array();
foreach($project_categories as $category) {
$project_category[] = '<a href="'.get_home_url().'/?project_category=' . $category->slug . '">' . $category->name . '</a>';
}
echo implode(', ', $project_category);
?>
</span> <!-- /end .cat-links -->
<?php } ?>
<?php // Project Tags
$project_tags = wp_get_object_terms($post->ID, 'project_tag');
if ($project_tags) {
$project_tag = array();
foreach($project_tags as $tag) {
$project_tag[] = '<a href="'.get_home_url().'/?project_tag=' . $tag->slug . '">' . $tag->name . '</a>';
} ?>
<span class="tag-links">
<?php _e('<span class="tag-links-title">Tagged: </span>', 'mav_framework'); ?> <?php echo implode(', ', $project_tag); ?>
</span> <!-- /end .tag-links -->
<?php } ?>
</footer> <!-- /end .entry-meta -->
</article> <!-- /end #project-<?php the_ID(); ?> .element -->
<?php endwhile; ?>
<?php wp_reset_query(); ?>
</section> <!-- /end #projects -->
</div> <!-- /end .wrapper -->
</section> <!-- /end #content -->
<?php endif; ?>
<?php
/**
* Add portfolio bottom quote
*/
if ($mav_data['portfolio_quote_text']) : ?>
<section id="portfolio-quote" class="clearfix">
<div class="wrapper clearfix">
<?php get_template_part('inc/block_portfolio_quote'); ?>
</div> <!-- /end .wrapper -->
</section> <!-- /end #portfolio-quote -->
<?php endif; ?>
<?php get_footer(); ?>
나는 당신이 원하는 것을 이해하기 어렵습니다. 작업 페이지의 링크를 표시 할 수 있습니까? – nunorbatista
@nunorbatista 답장을 보내 주셔서 감사합니다. URL이 아직 공개되지 않아 개인적으로 메시지를 보낼 수 있습니까? 또한 다음은 스크린 샷입니다. http://i.imgur.com/GCOzjgY.jpg 처음 방문했을 때 사용자가 보는 것입니다. 그러나 "새로운"필터 아래의 프로젝트가 착륙시 표시되기를 바랍니다. 따라서 "이전"은 착륙시 보이지 않으며 "이전"필터를 누를 때만 표시됩니다. 또는 "모두". 하지만 착륙시 '신품'항목 만 표시됩니다. –
나는 당신이 지금 원하는 것을 이해했습니다. 코드가 너무 커서 읽기 쉽도록 섹션을 나누어야합니다. 나는 지금 그것을 통과 할 시간이 없다, 나는 내일 그것을 할 것이다! – nunorbatista