Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/258.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用PHP仅显示特定类别的公文包帖子_Php_Wordpress - Fatal编程技术网

使用PHP仅显示特定类别的公文包帖子

使用PHP仅显示特定类别的公文包帖子,php,wordpress,Php,Wordpress,你好 我使用的主题有一个投资组合。公文包当前显示列出的所有类别。如何将其更改为仅显示特定类别,即设计和图像 下面是公文包模板页面的代码 <?php /* Template Name: Portfolio page */ ?> <?php get_header(); ?> <?php global $wp_query; $post = $wp_query->post; $gogo_select_portfolio_cat = get_post_meta($po

你好

我使用的主题有一个投资组合。公文包当前显示列出的所有类别。如何将其更改为仅显示特定类别,即设计和图像

下面是公文包模板页面的代码

<?php
/*
Template Name: Portfolio page
*/
?>

<?php get_header(); ?>
<?php
global $wp_query;
$post = $wp_query->post;
$gogo_select_portfolio_cat = get_post_meta($post->ID, 'gogo_select_portfolio_cat', true);
$gogo_portfolio_items_order = get_post_meta($post->ID, 'gogo_portfolio_items_order', true);
$gogo_portfolio_text_no_posts = get_post_meta($post->ID, 'gogo_portfolio_text_no_posts', true);
$gogo_select_portfolio_template = get_post_meta($post->ID, 'gogo_select_portfolio_template', true);
$gogo_select_portfolio_sidebar_position = get_post_meta($post->ID, 'gogo_select_portfolio_sidebar_position', true);
?>

<div class="block clearfix">

<header class="box-headline">
    <h4 class="main-headline"><?php the_title(); ?></h4>
</header>

<?php if ($gogo_select_portfolio_template=='portfolio-fourthcol') { 
    load_template(TEMPLATEPATH . '/lib/includes/portfolio/portfolio-4col.php');
} ?>

<?php if ($gogo_select_portfolio_template=='portfolio-threecol') { 
    load_template(TEMPLATEPATH . '/lib/includes/portfolio/portfolio-3col.php');
} ?>

<?php if ($gogo_select_portfolio_template=='portfolio-twocol') { 
    load_template(TEMPLATEPATH . '/lib/includes/portfolio/portfolio-2col.php');
} ?>

</div>

<?php get_footer();?>.

.
Portfolio-4col.php内容:

<ul id="filterOptions" class="horizontal" data-option-key="filter">
    <li><a class="selected" href="#filter" data-option-value="*">Show all</a></li>
    <?php
    $categories=  get_categories('taxonomy=portfolio_cat&title_li='); 
    foreach ($categories as $category){ ?>
    <li><a href="#filter" data-option-value=".<?php echo $category->slug;?>" title="Filter by <?php echo $category->name;?>"><?php echo $category->name;?></a></li>
    <?php }?> 
</ul>

<ul class="isotope-holder horizontal four-columns">
<?php rewind_posts(); ?>
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
query_posts( array( 
                     'post_type' => 'portfolio', 
                     'posts_per_page' => -1,
                     'ignore_sticky_posts' => 1
                     )
              );
$postcount = 0;
if ( have_posts() ) : while ( have_posts() ) : the_post(); $postcount++;?>

<!--Retrieve posts meta from custom post types -->
<?php
$gogo_portfolio_short_desc = get_post_meta($post->ID, 'gogo_portfolio_short_desc', true);
$gogo_portfolio_video_url = get_post_meta($post->ID, 'gogo_portfolio_video_url', true);
$gogo_portfolio_custom_link = get_post_meta($post->ID, 'gogo_portfolio_custom_link', true);
$gogo_portfolio_display_image_link = get_post_meta($post->ID, 'gogo_portfolio_display_image_link', true);
$gogo_portfolio_display_article_link = get_post_meta($post->ID, 'gogo_portfolio_display_article_link', true);
$gogo_portfolio_display_external_link = get_post_meta($post->ID, 'gogo_portfolio_display_external_link', true); ?>

<li class="element <?php $terms = wp_get_post_terms($post->ID,'portfolio_cat'); foreach ($terms as $term) {  echo ' ' .$term->slug. ' '; } ?>">
<div class="view view-sixth">
<?php if (has_post_thumbnail()) { ?>
<figure>
<?php $thumbnail = wp_get_attachment_image_src(get_post_thumbnail_id(), 'large');
echo '<img src="'.get_template_directory_uri().'/timthumb.php?src='.$thumbnail[0].'&amp;w=218&amp;h=200&amp;zc=1&amp;q=100&amp;s=1" alt="'.get_the_title().'" />';?>
</figure>
<?php } ?>

<div class="mask">
        <header class="box-headline">
            <?php echo '<h4><a href="'.get_permalink().'">'; echo ''.get_the_title().''; echo '</a></h4>'; ?>
        </header>
    <div class="content">
        <p><?php echo $gogo_portfolio_short_desc; ?></p>
        <a href="<?php echo get_permalink(); ?>" class="info"><span>Read More &raquo;</span></a>
    </div>
</div>

</div>
</li>
<?php endwhile; ?>
<?php else : ?>
<?php endif; ?>
</ul>

<script type="text/javascript">
var $j = jQuery.noConflict();
$j(window).load(function() {

var $jcontainer = $j('ul.isotope-holder');

$jcontainer.isotope({
  itemSelector : '.element',
  resizable: false, // disable normal resizing
  // set columnWidth to a percentage of container width
  masonry: { columnWidth: $jcontainer.width() / 4 }
});

// update columnWidth on window resize
$j(window).smartresize(function(){
  $jcontainer.isotope({
    // update columnWidth to a percentage of container width
    masonry: { columnWidth: $jcontainer.width() / 4}
  });
});

var $joptionSets = $j('#filterOptions'),
    $joptionLinks = $joptionSets.find('a');

$joptionLinks.click(function(){
  var $jthis = $j(this);
  // don't proceed if already selected
  if ( $jthis.hasClass('selected') ) {
    return false;
  }
  var $joptionSet = $jthis.parents('#filterOptions');
  $joptionSet.find('.selected').removeClass('selected');
  $jthis.addClass('selected');

  // make option object dynamically, i.e. { filter: '.my-filter-class' }
  var options = {},
      key = $joptionSet.attr('data-option-key'),
      value = $jthis.attr('data-option-value');
  // parse 'false' as false boolean
  value = value === 'false' ? false : value;
  options[ key ] = value;
  if ( key === 'layoutMode' && typeof changeLayoutMode === 'function' ) {
    // changes in layout modes need extra logic
    changeLayoutMode( $jthis, options )
  } else {
    // otherwise, apply new options
    $jcontainer.isotope( options );
  }

  return false;
});
});

</script>

    编辑:在看到公文包页面后。您可以根据需要更改query\u post命令

    query_posts( 'cat=id' );
    
    其中“id”是类别的编号id


    有关更多信息,请参阅。

    仅显示一个类别,而不是所有类别:

    替换此项:

    $categories =  get_categories('taxonomy=portfolio_cat&title_li=');
    
    为此:

    $categories[] = get_category('cat=4'); // replace 4 with category ID you're looking for
    

    我们需要解决这个问题的信息可能在
    portfolio-2col.php
    3col.php
    4col.php
    中,只要一个就可以让我们开始…感谢您的回答。正如你所说,我替换了它,但没有任何改变,只是现在它显示了所有类别的图像,并且它不再给我在顶部在不同类别之间切换的选项。嗯,你的最终目标是什么?你想做什么?看看下面的网站:。您将看到列出的类别。目前它显示了所有可用的猫。我只想让它显示猫的“标志”。我该怎么做?你能登录wordpress吗?查看你的公文包标签。你看,基本上我想做的是有2个Wordpress页面,每个页面显示4列公文包,每个页面只显示特定类别。目前,带有porfolio模板的每个页面都将显示所有可用的类别