Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

how to show an specific portfolio set on a page? WordPress

  • SOLVED

hello there, i'm trying to customized a theme i purchase for my site, but their support is really bad.
my question is it is possible to show only 1 portfolio set/category in a page?
if yes, how?

Answers (1)

2012-11-10

Arnav Joy answers:

yes you can use query_posts for it , as follows

query_posts('cat=1&posts_per_page=10);

see more for query posts

where cat=1 ,1 is the id of the category .

so you have to create a page template where you have to write this query post and then call this as normal wp loop

if(have_posts()):
while (have_posts()): the_post();
....
....
endwhile
endif

http://codex.wordpress.org/Function_Reference/query_posts


lchales comments:

thank god, but where i'm i suppose to input those query post?


Arnav Joy comments:

in the page template where you want to show this

if you do not have page template then you can create it , see here

http://codex.wordpress.org/Pages#Creating_Your_Own_Page_Templates


lchales comments:

i have a live page right now as i want it, the only thing is tat is showing all the categories in the portfolio.
can i do it in this page?
and off course how?
here is a link http://luischales.com/test1/?page_id=874


Arnav Joy comments:

can you share code of

portfolio-3r-php file


lchales comments:

<?php
/**
* Template Name: Portfolio 3 Columns + Right Sidebars
* The main template file for display portfolio page.
*
* @package WordPress
*/

if(!isset($hide_header) OR !$hide_header)
{
get_header();
}

/**
* Get Current page object
**/
$page = get_page($post->ID);

/**
* Get current page id
**/

if(!isset($current_page_id) && isset($page->ID))
{
$current_page_id = $page->ID;
}

//Get page description
$page_desc = get_post_meta($current_page_id, 'page_desc', true);

//Get page Sidebar
$page_sidebar = get_post_meta($current_page_id, 'page_sidebar', true);
if(empty($page_sidebar))
{
$page_sidebar = 'Portfolio Sidebar';
}

//If display on homepage then disable header
if(!isset($hide_header) OR !$hide_header)
{
?>

</div>

<!-- Begin content -->
<div id="content_wrapper">

<div class="page_caption">
<div class="caption_inner">
<div class="caption_header">
<h1 class="cufon"><span><?php the_title(); ?></span></h1>
<div class="caption_desc">
<?php echo stripcslashes($page_desc); ?>
</div>
</div>
<?php
//Include social icons
include (TEMPLATEPATH . "/templates/socials-icons.php");
?>
</div>
<br class="clear"/>
</div>
<br class="clear"/>

<div class="inner">

<!-- Begin main content -->
<div class="inner_wrapper">

<div class="standard_wrapper">

<!-- Begin portfolio content -->
<?php
$menu_sets_query = '';
$portfolio_items = -1;
$cur_post = 0;

//Get all portfolio items for paging
$args = array(
'numberposts' => $portfolio_items,
'order' => 'ASC',
'orderby' => 'menu_order',
'post_type' => array('portfolios'),
);
if(!empty($term))
{
$args['portfoliosets'].= $term;
}

$all_photo_arr = get_posts($args);
$total = count($all_photo_arr);
?>

<?php
//Get AJAX portfolio items
$ajax_portfolios_arr = array();

foreach($all_photo_arr as $key => $portfolio_item)
{
$portfolio_type = get_post_meta($portfolio_item->ID, 'portfolio_type', true);

if($portfolio_type == 'AJAX Portfolio Content')
{
$ajax_portfolios_arr[] = $portfolio_item;
}
}

$count_ajax_items = count($ajax_portfolios_arr);

foreach($ajax_portfolios_arr as $key => $portfolio_item)
{
//Get portfolio gallery ID
$portfolio_gallery_id = get_post_meta($portfolio_item->ID, 'portfolio_gallery_id', true);

//Get next and prev ajax item
if(isset($ajax_portfolios_arr[$key+1]))
{
$portfolio_next_id = $ajax_portfolios_arr[$key+1]->ID;
}
else
{
$portfolio_next_id = $ajax_portfolios_arr[0]->ID;
}

if(isset($ajax_portfolios_arr[$key-1]))
{
$portfolio_prev_id = $ajax_portfolios_arr[$key-1]->ID;
}
else
{
$portfolio_prev_id = $ajax_portfolios_arr[$count_ajax_items-1]->ID;
}
?>

<div id="ajax_<?php echo $portfolio_item->ID; ?>" class="ajax_portfolio_wrapper">
<a class="ajax_close" data-rel="<?php echo $portfolio_item->ID; ?>">x</a>
<a class="ajax_next ajax_portfolio_direction" data-rel="<?php echo $portfolio_next_id; ?>">→</a>
<a class="ajax_prev ajax_portfolio_direction" data-rel="<?php echo $portfolio_prev_id; ?>">←</a>
<?php
//If display featured image
if(empty($portfolio_gallery_id))
{
$image_thumb = '';

if(has_post_thumbnail($portfolio_item->ID, 'slide'))
{
$image_id = get_post_thumbnail_id($portfolio_item->ID);
$image_thumb = wp_get_attachment_image_src($image_id, 'slide', true);
}
?>
<img src="<?php echo $image_thumb[0]; ?>" alt="" class="portfolio_single_img img_shadow"/>
<?php
}
//If display image gallery
else
{
?>
<br class="clear"/>
<div id="portfolio_slider_<?php echo $portfolio_item->ID; ?>" class="flexslider portfolio">
<ul class="slides">
<?php
$args = array(
'post_type' => 'attachment',
'numberposts' => -1,
'post_status' => null,
'post_parent' => $portfolio_gallery_id,
'order' => 'ASC',
'orderby' => 'menu_order',
);
$portfolio_slider_arr = get_posts( $args );

foreach($portfolio_slider_arr as $key => $photo_item)
{
$image_slide = wp_get_attachment_image_src($photo_item->ID, 'slide', true);
?>

<li>
<img src="<?php echo $image_slide[0]; ?>" alt="<?php echo $photo_item->post_title; ?>"/>
</li>

<?php
}
?>
</ul>
</div>

<?php
//Get portfolio slider settings
$pp_portfolio_slider_timer = get_option('pp_portfolio_slider_timer');
if(empty($pp_portfolio_slider_timer))
{
$pp_portfolio_slider_timer = 5;
}

$pp_portfolio_slider_autoplay = get_option('pp_portfolio_slider_autoplay');
?>
<script type="text/javascript">
$j(window).load(function() {
$j('#portfolio_slider_<?php echo $portfolio_item->ID; ?>').flexslider({
animation: "fade",
<?php
if(empty($pp_portfolio_slider_autoplay))
{
?>
slideshow: false,
<?php
}
?>
controlNav: true,
slideshowSpeed: <?php echo $pp_portfolio_slider_timer*1000; ?>
});
});
</script>

<?php
}
?>
<div class="ajax_content">
<h4 class="center"><?php echo $portfolio_item->post_title; ?></h4><br/><hr/><br/>
<?php echo pp_apply_content($portfolio_item->post_content); ?>
</div>
</div>

<?php
}
?>
<?php
}
?>
<div class="sidebar_content portfolio_r">

<?php
if(!empty($page->post_content) && !is_home())
{
echo pp_apply_content($page->post_content).'<br class="clear"/><br/>';
}
?>

<?php
if(isset($all_photo_arr) && !empty($all_photo_arr))
{

?>
<div class="portfolio-content section content clearfix">
<?php

foreach($all_photo_arr as $key => $portfolio_item)
{
$cur_post++;
$image_url = '';

if(has_post_thumbnail($portfolio_item->ID, 'portfolio3l'))
{
$image_id = get_post_thumbnail_id($portfolio_item->ID);
$image_url = wp_get_attachment_image_src($image_id, 'portfolio3l', true);
$full_image_url = wp_get_attachment_image_src($image_id, 'full', true);
}

$portfolio_link_url = get_post_meta($portfolio_item->ID, 'portfolio_link_url', true);

if(empty($portfolio_link_url))
{
$permalink_url = get_permalink($portfolio_item->ID);
}
else
{
$permalink_url = $portfolio_link_url;
}

$portfolio_item_class = 'one_third portfolio';

$pp_portfolio_image_height = 130;
?>
<div class="<?php echo $portfolio_item_class; ?>">

<?php
$portfolio_type = get_post_meta($portfolio_item->ID, 'portfolio_type', true);
$portfolio_video_id = get_post_meta($portfolio_item->ID, 'portfolio_video_id', true);
switch($portfolio_type)
{
case 'External Link':
default:
?>
<div class="portfolio195_shadow">
<a href="<?php echo $permalink_url; ?>">
<img src="<?php echo $image_url[0]?>" alt="" class="portfolio_img"/>
<div class="portfolio195_overlay">
<div class="portfolio195_overlay_inner">
<h5><?php echo $portfolio_item->post_title; ?></h5>
<hr/>
<?php echo pp_substr($portfolio_item->post_excerpt, 80); ?>
<div class="portfolio_type_wrapper">
<img src="<?php echo get_stylesheet_directory_uri(); ?>/images/icon_link.png" alt="" class=""/>
</div>
</div>
</div>
</a>
</div>

<?php
break;
//end external link

case 'Portfolio Content':
default:
?>
<div class="portfolio195_shadow">
<a href="<?php echo get_permalink($portfolio_item->ID); ?>">
<img src="<?php echo $image_url[0]?>" alt="" class="portfolio_img"/>
<div class="portfolio195_overlay">
<div class="portfolio195_overlay_inner">
<h5><?php echo $portfolio_item->post_title; ?></h5>
<hr/>
<?php echo pp_substr($portfolio_item->post_excerpt, 80); ?>
<div class="portfolio_type_wrapper">
<img src="<?php echo get_stylesheet_directory_uri(); ?>/images/icon_link.png" alt="" class=""/>
</div>
</div>
</div>
</a>
</div>

<?php
break;
//end Portfolio Content

case 'AJAX Portfolio Content':

//Get portfolio gallery ID
$portfolio_gallery_id = get_post_meta($portfolio_item->ID, 'portfolio_gallery_id', true);
?>
<div class="portfolio195_shadow">
<a href="javascript:;" data-rel="<?php echo $portfolio_item->ID; ?>" class="ajax_portfolio_link">
<img src="<?php echo $image_url[0]?>" alt="" class="portfolio_img"/>
<div class="portfolio195_overlay">
<div class="portfolio195_overlay_inner">
<h5><?php echo $portfolio_item->post_title; ?></h5>
<hr/>
<?php echo pp_substr($portfolio_item->post_excerpt, 80); ?>
<div class="portfolio_type_wrapper">
<img src="<?php echo get_stylesheet_directory_uri(); ?>/images/icon_link.png" alt="" class=""/>
</div>
</div>
</div>
</a>
</div>

<?php
break;
//end AJAX Portfolio Content

case 'Image':
?>
<div class="portfolio195_shadow">
<a href="<?php echo $full_image_url[0]; ?>" class="img_frame">
<img src="<?php echo $image_url[0]?>" alt="" class="portfolio_img"/>
<div class="portfolio195_overlay">
<div class="portfolio195_overlay_inner">
<h5><?php echo $portfolio_item->post_title; ?></h5>
<hr/>
<?php echo pp_substr($portfolio_item->post_excerpt, 80); ?>
<div class="portfolio_type_wrapper">
<img src="<?php echo get_stylesheet_directory_uri(); ?>/images/icon_image.png" alt="" class=""/>
</div>
</div>
</div>
</a>
</div>

<?php
break;
//end image

case 'Youtube Video':
?>
<div class="portfolio195_shadow">
<a href="#video_<?php echo $portfolio_video_id; ?>" class="lightbox_youtube">
<img src="<?php echo $image_url[0]?>" alt="" class="portfolio_img"/>
<div class="portfolio195_overlay">
<div class="portfolio195_overlay_inner">
<h5><?php echo $portfolio_item->post_title; ?></h5>
<hr/>
<?php echo pp_substr($portfolio_item->post_excerpt, 80); ?>
<div class="portfolio_type_wrapper">
<img src="<?php echo get_stylesheet_directory_uri(); ?>/images/icon_video.png" alt="" class=""/>
</div>
</div>
</div>
</a>
</div>

<div style="display:none;">
<div id="video_<?php echo $portfolio_video_id; ?>" class="embed-container">

<iframe title="YouTube video player" width="900" height="488" src="http://www.youtube.com/embed/<?php echo $portfolio_video_id; ?>?theme=dark&rel=0&wmode=transparent" frameborder="0" allowfullscreen></iframe>

</div>
</div>

<?php
break;
//end youtube

case 'Vimeo Video':
?>
<div class="portfolio195_shadow">
<a href="#video_<?php echo $portfolio_video_id; ?>" class="lightbox_vimeo">
<img src="<?php echo $image_url[0]?>" alt="" class="portfolio_img"/>
<div class="portfolio195_overlay">
<div class="portfolio195_overlay_inner">
<h5><?php echo $portfolio_item->post_title; ?></h5>
<hr/>
<?php echo pp_substr($portfolio_item->post_excerpt, 80); ?>
<div class="portfolio_type_wrapper">
<img src="<?php echo get_stylesheet_directory_uri(); ?>/images/icon_video.png" alt="" class=""/>
</div>
</div>
</div>
</a>
</div>

<div style="display:none;">
<div id="video_<?php echo $portfolio_video_id; ?>" class="embed-container">

<iframe src="http://player.vimeo.com/video/<?php echo $portfolio_video_id; ?>?title=0&amp;byline=0&amp;portrait=0&amp;color=ffffff" width="900" height="506" frameborder="0"></iframe>

</div>
</div>

<?php
break;
//end vimeo

case 'Self-Hosted Video':

//Get video URL
$portfolio_mp4_url = get_post_meta($portfolio_item->ID, 'portfolio_mp4_url', true);
$preview_image = wp_get_attachment_image_src($image_id, 'large', true);
?>
<div class="portfolio195_shadow">
<a href="#video_self_<?php echo $key; ?>" class="lightbox_vimeo">
<img src="<?php echo $image_url[0]?>" alt="" class="portfolio_img"/>
<div class="portfolio195_overlay">
<div class="portfolio195_overlay_inner">
<h5><?php echo $portfolio_item->post_title; ?></h5>
<hr/>
<?php echo pp_substr($portfolio_item->post_excerpt, 80); ?>
<div class="portfolio_type_wrapper">
<img src="<?php echo get_stylesheet_directory_uri(); ?>/images/icon_video.png" alt="" class=""/>
</div>
</div>
</div>
</a>
</div>

<div style="display:none;">
<div id="video_self_<?php echo $key; ?>" class="embed-container">

<div id="self_hosted_vid_<?php echo $key; ?>">JW Player goes here</div>

<script type="text/javascript">
jwplayer("self_hosted_vid_<?php echo $key; ?>").setup({
flashplayer: "<?php echo get_stylesheet_directory_uri(); ?>/js/player.swf",
file: "<?php echo $portfolio_mp4_url; ?>",
image: "<?php echo $preview_image[0]; ?>",
width: 900,
height: 488,
});
</script>

</div>
</div>

<?php
break;
//end self-hosted video
?>

<?php
}
//end switch
?>

</div>

<?php

}
//End foreach loop

?>

</div>
<?php

}
//End if have portfolio items
?>
<br class="clear"/>
</div>

<div class="sidebar_wrapper">

<div class="sidebar_top"></div>

<div class="sidebar">

<div class="content">

<ul class="sidebar_widget">
<?php dynamic_sidebar($page_sidebar); ?>
</ul>

</div>

</div>
<br class="clear"/>

<div class="sidebar_bottom"></div>
</div>

<?php
if(!isset($hide_header) OR !$hide_header)
{
?>
</div>
<!-- End main content -->

<br class="clear"/><br/><br/>

</div>

</div>
<!-- End content -->


<?php get_footer(); ?>
<?php
}
?>


Arnav Joy comments:

so your portfolio catrgory is a custom taxonomy so you have to edit $args array , find following in your code

$args = array(

'numberposts' => $portfolio_items,

'order' => 'ASC',

'orderby' => 'menu_order',

'post_type' => array('portfolios'),


);


and use this in place of it

$args = array(

'numberposts' => $portfolio_items,

'order' => 'ASC',

'orderby' => 'menu_order',

'post_type' => array('portfolios'),

'tax_query' => array(
array(
'taxonomy' => 'your_tax_name',
'field' => 'slug',
'terms' => 'term_slug'
)
) ,

);

i have added following code

<code> 'tax_query' => array(
array(
'taxonomy' => 'your_tax_name',
'field' => 'slug',
'terms' => 'term_slug'
)
) ,
</code>

so mail thing is here

array(
'taxonomy' => 'your_tax_name',
'field' => 'slug',
'terms' => 'your_term_slug'
)



you have to change two things

1.your_tax_name
2.your_term_slug

which you can find , when editing portfolio category which you want to use , click on the edit link and see the url there you will get the name of the taxonomy and at edit screen you will get the slug , use it and let me know if there is any problem doing it.


lchales comments:

i reply to your message with the login info, did you get it?
also if i edit that page template all the pages i create with that template will show only the category on it.
and i need to have several pages showing different portfolios.