Jump to content

Recommended Posts

hello everyone!

 

I am having some issues customizing a wordpress theme, and have spent countless ours reading and trying everything to no avail!

 

problem:

 

i have a theme that uses a portfolio setup. it pulls each portfolio post and displays them in a grid like fasion ( thumbnails ) it then uses filters to sort them and has links above to sort apples & oranges etc. By default it displays ALL posts, unfiltered.

 

I am trying to set it to pull specific filters by default.

 

the template code as follows:

<!-- PORTFOLIO -->
<div class="portfolio2">

        <!-- Filters -->
        <ul class="filter_list">
            <li><a href="#all" title="all" class="current">ALL</a></li>
            <?php 
            rewind_posts();
            $catz =  get_terms('portfolio2', 'orderby=count&hide_empty=0');
                foreach($catz as $cat1){ 
                    echo '<li><a href="#'.$cat1->slug.'" title="'.$cat1->slug.'"><span>'.$cat1->name.'</span></a></li>';
                }
            ?>
        </ul>
        <!-- /Filters -->

        <br class="clear" />
        
<div id="portfolio">
<?php
rewind_posts();
// Counter...
$slider_count = get_option('dcb_portfolio_counter');
// Query
query_posts("showposts=".$slider_count."&post_type=portfolio");
while(have_posts()):the_post();
// Thumbnail
$thumbnailer=get_the_post_thumbnail($post->ID,"slider");
preg_match ('/src="(.*)" class/',$thumbnailer,$link); 
// Custom fields
$custom_link = get_post_meta($post->ID, "link", true);
$custom_lightbox = get_post_meta($post->ID, "lightbox", true);
$custom_caption = get_post_meta($post->ID, "caption", true);
$excerpt = get_the_excerpt();
$catz = wp_get_object_terms($post->ID,'portfolio2');
foreach($catz as $cat1) { 
$currcat = $cat1->slug;
$catname = $cat1->name;
break;
}
?>
<!-- Grid Item -->
<div class="portfolio_item grid_item <?php echo $currcat; ?>">
    <div class="grid_infos">
        <div class="grid_infos_container">
        <h5><?php the_title(); ?></h5>
        <p><?php echo limit(150, $excerpt); ?></p>
        <?php
        	if($custom_lightbox !== "") {
			echo '<a href="'.$custom_lightbox.'" rel="prettyPhoto['.$catname.']" class="zoom">zoom</a>'; 
		} else {
			echo '<a href="'.$link[1].'" rel="prettyPhoto['.$catname.']" class="zoom">zoom</a>';
		}
	?>
        <?php
        	if($custom_link !== "") {
			echo '<a href="'.$custom_link.'" class="continue">view</a>'; 
		} else {
			echo '<a href="';
			the_permalink();
			echo '" class="continue">view</a>'; 
		}
	?>
        </div>
    </div>
    <?php $attr = array('class' => "", 'title' => $custom_caption);
		the_post_thumbnail('square_size',$attr); ?>
</div>
<!-- /Grid Item -->
<?php endwhile;?>
</div>
<br>


</div>
<!-- /PORTFOLIO -->

 

And the functions.php taxonomy:

// PORTFOLIO
add_action('init', 'portfolio_register');
add_action('init', 'add_default_boxez2');

function add_default_boxez2() {
register_taxonomy("portfolio2", array("portfolio"), array("hierarchical" => true, "label" => "Portfolio filters", "singular_label" => "Category", "rewrite" => true,"query_var"=>true));
}
function portfolio_register() {

$labels = array(
	'name' => _x('Portfolio', 'post type general name'),
	'singular_name' => _x('portfolio Item', 'post type singular name'),
	'add_new' => _x('Add New', 'portfolio item'),
	'add_new_item' => __('Add New portfolio Item'),
	'edit_item' => __('Edit portfolio Item'),
	'new_item' => __('New portfolio Item'),
	'view_item' => __('View portfolio Item'),
	'search_items' => __('Search portfolio'),
	'not_found' =>  __('Nothing found'),
	'not_found_in_trash' => __('Nothing found in Trash'),
	'parent_item_colon' => ''
);

$args = array(
	'labels' => $labels,
	'public' => true,
	'publicly_queryable' => true,
	'show_ui' => true,
	'query_var' => true,
	'menu_icon' => get_stylesheet_directory_uri() . '/images/portfolio.png',
	'rewrite' => true,
	'capability_type' => 'post',
	'hierarchical' => false,
	'menu_position' => null,
	'supports' => array('title','editor','excerpt','thumbnail','categories','custom-fields'),
  ); 

register_post_type( 'portfolio' , $args );
}

 

 

I have spent hours trying to configure the "query_posts("showposts=".$slider_count."&post_type=portfolio");" to pull the filters or id's with no luck.

is there something im missing?

 

i am willing to pay or donate to the site if anyone can help out.

thanks for your time!

 

Chris

 

Link to comment
https://forums.phpfreaks.com/topic/249012-help-with-query_posts-from-portfolio/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.