Forums

Additional category type for posts and pages (2 posts)

  1. Zygfryd Matuszewski
    Member
    Posted 10 months ago #

    Hi
    I'm wondering how to add an additional category type tree for posts and pages (I do not want to do it in the same category tree I use already).

    Then when I match each of posts and pages to this external category type - I want to display seach results divided by categories.

    Eg.
    POST A - category 1
    POST B - category 1
    POST C - category 2
    PAGE X - category 4
    PAGE Y - category 3
    PAGE Z - category 3

    And search results are:
    category 1:
    -POST A
    -POST B
    category 2:
    -POST C
    category 3:
    -POST Y
    -POST Z
    category 4:
    -POST X

    Any ideas?

  2. Zygfryd Matuszewski
    Member
    Posted 10 months ago #

    I've already prepared search.php for this matter:

    <?php
    /**
     * The template for displaying Search Results pages.
     *
     * @package WordPress
     * @subpackage Twenty_Ten
     * @since Twenty Ten 1.0
     */
    
    get_header(); ?>
    
    	<div class="content">
    			<?php
    				$s = get_search_query();
    			?>
    	<div class="search">
    		<div class="categoryThumbs">
    		<?php if (have_posts()) : ?>
    			<h1 class="page-title">
    				Wsearche: <?php /* Search Count */ $allsearch = &new WP_Query("s=$s&showposts=-1"); $key = wp_specialchars($s, 1); $count = $allsearch->post_count; _e(''); _e(''); echo $key; _e(''); _e(' &mdash; '); echo $count . ' '; _e('wyników'); wp_reset_query(); ?>:</h1>
    		<?php endif;?>
    			<?php query_posts("s='$s'&category_name=t"); ?>
    				<?php if (have_posts()) : ?>
    					<?php $blogResults=0; ?>
    				<?php while (have_posts()) : the_post(); ?>
    					<?php
    						$blogResults++;
    					?>
    				<?php endwhile; ?>
    					<h2><?php echo $blogResults; ?> Ptw</h2>
    					<?php while (have_posts()) : the_post(); ?>
    					<div class="films">
    						<div class="thumb" style="float:left;">
    							<a href="<?php the_permalink() ?>"><?php
    if(has_post_thumbnail()) :?>
    <div class="left">
    <div class="image_frame">path to some image here</div>
    <?php the_post_thumbnail(); ?>
    </div>
    <?php else :?>ni
    <?php endif;?></a>
    						</div>
    						<h3 id="post-<?php the_ID(); ?>"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h3>
    						<div class="entry">
    							<?php the_excerpt() ?>
    						</div>
    					</div>
    					<?php endwhile; ?>
    				<?php endif;?>
    				<?php query_posts("s='$s'&category_name=y"); ?>
    				<?php if (have_posts()) : ?>
    					<?php $blogResults=0; ?>
    				<?php while (have_posts()) : the_post(); ?>
    					<?php
    						$blogResults++;
    					?>
    				<?php endwhile; ?>
    					<h2><?php echo $blogResults; ?> Attti</h2>
    					<?php while (have_posts()) : the_post(); ?>
    					<div class="films">
    						<div class="thumb" style="float:left;">
    								<a href="<?php the_permalink() ?>"><?php
    if(has_post_thumbnail()) :?>
    <div class="left">
    <div class="image_frame">path to some image here</div>
    <?php the_post_thumbnail(); ?>
    </div>
    <?php else :?>nie ma obrazka
    <?php endif;?></a>
    						</div>
    						<h3 id="post-<?php the_ID(); ?>"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h3>
    						<div class="entry">
    							<?php the_excerpt() ?>
    						</div>
    					</div>
    					<?php endwhile; ?>
    				<?php endif;?>
    
    				<?php query_posts("s='$s'&category_name=x"); ?>
    				<?php if (have_posts()) : ?>
    					<?php $blogResults=0; ?>
    				<?php while (have_posts()) : the_post(); ?>
    					<?php
    						$blogResults++;
    					?>
    				<?php endwhile; ?>
    					<h2><?php echo $blogResults; ?> Sxu</h2>
    					<?php while (have_posts()) : the_post(); ?>
    					<div class="films">
    						<div class="thumb" style="float:left;">
    							<a href="<?php the_permalink() ?>"><?php
    if(has_post_thumbnail()) :?>
    <div class="left">
    <div class="image_frame">path to some image here</div>
    <?php the_post_thumbnail(); ?>
    </div>
    <?php else :?>no
    <?php endif;?></a>
    						</div>
    						<h3 id="post-<?php the_ID(); ?>"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h3>
    						<div class="entry">
    							<?php the_excerpt() ?>
    						</div>
    					</div>
    					<?php endwhile; ?>
    				<?php endif;?>
    		<div class="spacer"></div>
    		</div>
    	</div>
    </div>
    
    <?php get_sidebar(''); ?>
    <?php get_footer(); ?>

Reply

You must log in to post.

About this Topic