classifieds to look the same on search page as on "classifieds" page

Ok, you plugin is amazing :slight_smile: love it!

Now, when i hit "Classifieds" page i get a list of published classifieds and that's OK...
I have set custom post type to be shown on "Search" results page BUT... when i hit Search, i get list of custom posts but i need them to look exactly like on "Classifieds" page, if you know what i mean... not just list of posts without any formatting.
Also, i would like to setup my homepage to display all classifieds, i've tried to do that by assigning static page "classifieds" to my homepage but i get a message "this is virtual page..."
Naturally, next thing is if i want my homepage to show latest posts (set to custom post type classifieds) again i get just non-formatted posts while i want them to look like on "Classifieds" page...

Your help would be very highly appreciated if i solve this issue.

Many thanks,
Alek

  • Jack Kitterhing

    Hi there Alek,

    I hope you are well today and thanks for your question.

    How are you currently searching them, are you using a custom search query?

    For displaying them on the home page you'll need to create a custom loop, or edit the existing loop within your theme, as shown here http://codex.wordpress.org/Post_Types

    For example (taken from the above link). `$args = array( 'post_type' => 'product', 'posts_per_page' => 10 );
    $loop = new WP_Query( $args );
    while ( $loop->have_posts() ) : $loop->the_post();
    the_title();
    echo '<div class="entry-content">';
    the_content();
    echo '</div>';
    endwhile;`

    I'm here to help :slight_smile:

    Thank you!

    Kind Regards
    Jack.

  • Aleksandar

    Hi Jack,

    Many thanks for your reply.
    I am having difficulties with adding that loop, especially as i am not so familiar with php :slight_smile:

    Code of my index.pxp page where i would like to display classifieds is:

    <?php get_header(); ?>
    
    <div id="content">
    
    <div class="entry">
    
    		<?php $my_query = new WP_Query('showposts=1');
            while ($my_query->have_posts()) : $my_query->the_post();
            $do_not_duplicate = $post->ID; ?>
    
            <div class="post new" id="post-<?php the_ID(); ?>">
    
            <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h2>
    
            <div class="storycontent">
    		<?php the_content(__('More Info...')); ?>
    	</div>
    
            </div><!--post-->
            <?php endwhile; ?>
    
            <?php if (have_posts()) : while (have_posts()) : the_post();
            if( $post->ID == $do_not_duplicate ) continue; update_post_caches($posts); ?>
    
            <div class="post" id="post-<?php the_ID(); ?>">
    
            <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h2>
    
            <div class="storycontent">
    		<?php the_content(__('More Info...')); ?>
    	</div>
    
            </div><!--post-->
    		<?php endwhile; ?>
    
            <div class="alignleft"><?php next_posts_link('Older Entries') ?></div>
            <div class="alignright"><?php previous_posts_link('Newer Entries') ?></div>
            <br clear="all" />
    
    		<?php else : ?>
    		<?php endif; ?> 
    
    </div><!-- end of entry -->
    </div><!--content-->
    
    <?php get_footer(); ?>

    Can you please look into it quickly and give me some guides what code and where to put it.

    Many thanks,
    Alek

    p.s. from this example, i think i will sort out search page on my own

  • Jack Kitterhing

    Hi there Alek,

    Something like

    $args = array(
    	'post-type' => 'classifieds', 'posts_per_page' => 10 );
    		$loop = new WP_QUERY( $args );
    			while ( $loop->have_posts()) : $loop->the_post();
    				the_title();
    					echo '<div class="entry-content">';
    						the_content();
    							echo '</div>';
    									endwhile;
    
    echo do_shortcode('[custom_fields_block wrap="table"]');

    Will query the classifieds post type, the last part the echo do_shortcode will output the custom fields from the attached post type, this must be used within the loop, if you want, but I'd actually recommend using

    echo do_shortcode('[custom_fields_block wrap="table"]');

    Within the loop.

    And then a custom template for the actual query of the posts.

    Which theme is that your using?

    Thanks!

    Kind Regards
    Jack

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.