Classifier Ads on Front Page

Hi!

This time i will share something that my friend from Kansas, Toby, ask me. Yesterday, he asked if could it possible to displaying the ads on the front page? The default format on the front page is to displaying the latest posts.

Classifier. - Premium Classified Ads WordPress Theme

Classifier – Latest posts on front page

At the image above, you can see what is Toby ask to me.

To change this section to displaying your latest ads is very simple. You just have to modify 2 files: index.php and content-post.php.

Step#1

On this first step, you have to modify a file named index.php. Find out this code:

<?php $wp_query = new WP_Query("post_type=post&paged=$paged"); ?>

Modify that code become:

<?php $wp_query = new WP_Query("post_type=ad&paged=$paged"); ?>

Once you made it, your front page already displaying your latest ads on your front page, but the price is not yet displayed.

Step#2

On this step, you will modify a file named content-posts.php in order to displaying the price. Find out this code:

<figure class="post-image">
<?php colabs_image('width=239&height=143&size=thumbnail'); ?>
</figure>

Modify that code become:

<figure class="post-image">
<?php colabs_image('width=239&height=143&size=thumbnail'); ?>
<?php $colabs_price = get_post_meta($post->ID, 'colabs_price', true); ?>
<span class="price"><?php if ( !empty($colabs_price) ) colabs_get_price_legacy($post->ID); else colabs_get_price($post->ID, 'colabs_price'); ?></span>
</figure>

And done!

Advertisements

41 thoughts on “Classifier Ads on Front Page

    • Hi Boat,

      yes you can add this variable when declaring the loop:

      posts_per_page= INT

      about the description, is it the slider? if yes, you can modify a file named ‘featured-main.php’ (inside includes folder).

      remove this code:

  1. Hi Tandamerah . I am using classifier theme . I am facing the problem like secondary menus sub menu comes after the slider . And also another problems are the all catagories and location does not show all the fields i typed n sometimes does not fully appear. Thanks for the help.

    • HI Zayant,

      For the menu, do you already configure the menus? (WordPress dashboard > Appearance > Menus).

      for the other problem, could you explain more details? is it about the search result?

      • Hi Tandamerah . First of all thank you for the response. The first one i solved it while the other one the with category n location . When i add the ad with the desired category n location only it comes into the homepage drop down menu. Thank you for the help.

      • Thank you, yes i have fixed it; but I have additional issue and if you can help I will really appreciate: 

        Is there anyway I can add buy now to the item page i.e woocommerce “buy now” button, as an option for buyer who which to purchase immediately.

        I look forward to your reply. 

        Kind Regards

        George 

      • hi geovellon3,

        it is quite hard to make a buy button to be displayed since as you know that Classifier doesn’t have that feature either.

        There is no option to buy a product that listed on your site while using Classifier. The only option available is to contact the ad’s lister. So, i think there is no way to make what you asked

      • Hi Alex,

        Nice question, hope if everyone can also learn from this query. This is the new query you can use on the main page:

        <div class="row main-container">
        			<div class="main-content col9">
        				<?php
        						  if ( get_query_var('paged') ) { $paged = get_query_var('paged'); } else if ( get_query_var('page') ) {$paged = get_query_var('page'); } else {$paged = 1; }
         
        							$temp = $wp_query;  // re-sets query
        							$wp_query = null;   // re-sets query
        							$args = array( 'post_type' => COLABS_POST_TYPE, 'orderby'=>'date', 'order'=>'DESC', 'posts_per_page' => 2, 'paged' => $paged);
        							$wp_query = new WP_Query();
        							$wp_query->query( $args );
        				?>
        
        					<ul class="post-list">
        					<?php while ($wp_query->have_posts()) : $wp_query->the_post() ?>
        										<li class="posting">
        							<h3><a href="<?php the_permalink();?>"><?php the_title();?></a></h3>
        							
        							<?php $colabs_price = get_post_meta($post->ID, 'colabs_price', true); ?>
        							<span class="price"><?php if ( !empty($colabs_price) ) colabs_get_price_legacy($post->ID); else colabs_get_price($post->ID, 'colabs_price'); ?></span>
        							
        							<?php colabs_custom_excerpt(20,'');?>
        							<div class="more"><a href="<?php the_permalink();?>"><?php _e('read more','colabsthemes');?></a></div>
        						</li>
        							 <?php endwhile; ?>
            <nav>
               <?php 
                   paginate(); 
                   $wp_query = null;
                   $wp_query = $temp; // Reset
               ?>
            </nav>	
        				</ul>
        			
        			</div>
        		</div>
        

        then put this code into your functions.php file:

        	function paginate() {
        global $wp_query, $wp_rewrite;
        $wp_query->query_vars['paged'] > 1 ? $current = $wp_query->query_vars['paged'] : $current = 1;
         
        $pagination = array(
            'base' => @add_query_arg('page','%#%'),
            'format' => '',
            'total' => $wp_query->max_num_pages,
            'current' => $current,
            'show_all' => false,
            'type' => 'list',
            'next_text' => '&raquo;',
            'prev_text' => '&laquo;'
            );
         
        if( $wp_rewrite->using_permalinks() )
            $pagination['base'] = user_trailingslashit( trailingslashit( remove_query_arg( 'page', get_pagenum_link( 1 ) ) ) . '?page=%#%/', 'paged' );
         
        if( !empty($wp_query->query_vars['s']) )
            $pagination['add_args'] = array( 's' => get_query_var( 's' ) );
         
        echo paginate_links( $pagination );
        }   
        

        By this new query, it should be work (already tested)

      • If anyone of you here can’t get the modification work on your site, you can download the modified index.php file here. These modification will require the modification on functions.php (already mentioned above).

        You can download it at: http://1drv.ms/ZmWoMR

        If you found that the pagination can’t be used to backward, install WP Page Navi (https://wordpress.org/plugins/wp-pagenavi/) then edit the index.php file. Find out this code:

        <?php
        paginate();
        $wp_query = null;
        $wp_query = $temp; // Reset
        ?>
        

        Modify it become:

        <?php
        wp_pagenavi();
        $wp_query = null;
        $wp_query = $temp; // Reset
        ?>
        

        Update:

        recently i found that some hosting can’t working with the numbered pagination. The one that will work is next/previous pagination. To test it, you can download the ‘index.php’ file from: http://1drv.ms/1wbQPZT

  2. Hello tandamerah,
    I’m asking for a help i’m not so good in php i’m a beginner. My problem is that when i submit an ad it works good in my website but i can’t visualise it and see details you see when you click on the ad link it shows me a blank page.
    So i haven’t understand where is the problem exactly !!
    Thank you and i’m waiting for an answer.

    Walid

    • hi junior,

      have you flush your permalink? you can do it by going to: WordPress dashboard > Settings > permalink.

      make sure if you are not using the default value, change it for example to post name, then click on the save change button

  3. Hi tandamerah,

    I am using classifier theme for free ads, even featured ads are free, I dont know if this is the reason featured ads tab neither its slider appear on front page? How to make slider appear?
    I appriciate your help!

    • Hi Sobia,

      To displaying the slider, make sure if your ad have a ‘tag’. If you already make sure of it, you can go to: WordPress dashboard > classifier > dashboard > front page settings.

      on that page, you will see an option named ‘featured tag’. you can displaying the featured ad on the slider based on its tag.

      • I appreciate your timely reply, thanks a lot! I am having another problem too, I have added two levels of locations provinces and then cities, there is no proper distinction but just a tab in drop down list. that makes it confusing, i want to display a separate list against each province just like kijiji.ca “my location” does, can i get some help please!

  4. Now I have created myself. This is the right way:

    In the main page (index,php):


    For other, in the content-post.php for show price:


    <div >

    ID, ‘colabs_price’, true); ?>
    ID); else colabs_get_price($post->ID, ‘colabs_price’); ?>

    now works well, see the front page of http://www.madeindj.com – Show the lasted and best ads, whith pagination work perfect.
    I think this may be helpful in the future to someone else … Regards

  5. Now I have created myself. This is the right way:
    
    In the main page (index,php):
    
        
        
          
            
            
          
          
            
            
            
    													 
    												    
          
          
            
            
            
    													 
    												    
          
        
            
      
      
    
    
    
    For other, in the content-post.php for show price:
    
    
    <div >
    
    	
    				
    		
    
    ID, 'colabs_price', true); ?>
    ID); else colabs_get_price($post->ID, 'colabs_price'); ?>
    
    				
    		
    
    now works well, see the front page of www.madeindj.com - Show the lasted and best ads, whith pagination work perfect.
    I think this may be helpful in the future to someone else ... Regards
    
  6. Hi tandamerah,

    Is there any way i can make posts/images in posts appear in the featured slider, just like Ads? Currently, only Ads having relevant tag are displayed in the featured slider on front page. i want to display posts also.

    i tried modifying the featured-main.php for the classifier theme. But it did not work. i do not want to use any plugins here.

    Could you please help me here?

    Thanks,
    Sowmini

    • Hi,

      You can’t displaying 2 custom post types on a single wp_query. If you want to switch the slider to displaying your post, you can open a file named ‘featured-main.php’ (wp-content > themes > classifier > includes). Find out this code:

      $slides = get_posts(
          array(
              'post_type' => COLABS_POST_TYPE ,
              'numberposts' => $featposts,
              'tax_query' => array(
                  array(  'taxonomy' => COLABS_TAX_TAG,
                          'field' => 'id',
                          'terms' => $tag_array
                          ))
              ));
      

      Modify it become:

      $test = get_option(colabs_featured_tags);
      $slides = get_posts(
          array(
              'post_type' => 'post' ,
              'numberposts' => $featposts,
              'cat'
              )); =>
      

      Then open a file named ‘theme-options.php’ (wp-content > themes > classifier > includes). Find out this code:

      $options[] = array( "name" => __("Featured Tag", "colabsthemes" ),
                          "desc" => __("Add comma separated list for the tags that you would like to have displayed in the featured section on your homepage. For example, if you add 'tag1, tag3' here, then all properties tagged with either 'tag1' or 'tag3' will be shown in the featured area.", "colabsthemes" ),
                          "id" => $shortname."_featured_tags",
                          "std" => "",
                          "type" => "text");
      

      Modify it become:

      $options[] = array( "name" => __("Featured Tag", "colabsthemes" ),
                          "desc" => __("Add comma separated list for the tags that you would like to have displayed in the featured section on your homepage. For example, if you add 'tag1, tag3' here, then all properties tagged with either 'tag1' or 'tag3' will be shown in the featured area.", "colabsthemes" ),
                          "id" => $shortname."_featured_tags",
                          "std" => "",
                          "type" => "select",
       "options" => $colabs_categories
      );
      
    • Hi,

      By default, a ‘page’ doesn’t have any comment form. If you want to have one, then you will need to modify a file named ‘page.php’.

      You can find out this file via FTP at directory: wp-content > themes > classifier.

      Open the file and find out this code

      
      	     <?php comments_template( '', true ); ?>
      

      Modify it become:

      
      	     <?php comments_template( '', true ); ?>
      		<?php endwhile;?>
      

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s