Page 1 of 4 123 ... LastLast
Results 1 to 10 of 34

Thread: Featured Ads at Top of Category

  1. #1
    Thread Starter
    Member mossj88's Avatar
    Join Date
    Feb 2012
    Location
    England
    Posts
    60
    Thanks
    3
    Thanked 9 Times in 7 Posts

    Featured Ads at Top of Category

    PLEASE DO NOT ASK FOR SUPPORT IN THIS THREAD - Support Thread here

    What
    This code puts 5 random featured ads (in that category) to the top of the list, it also won't show the same ad twice (if it's one of the featured ads randomly selected it won't show again in the normal list). This is how it works on the big industry players (gumtree - refresh the page and see the featured ads change)

    Edits
    There are 4 file edits in 3 files
    • loop-ad_listing.php
    • style.css
    • taxonomy-ad_cat.php

    MAKE SURE TO BACK THEM UP!

    Thanks
    Thanks to classifiedsnext who in this thread provided the code that started me off

    Steps
    Edit the following files in the way described
    1. taxonomy-ad_cat.php
      Around line 40 you will find
      Code:
      <?php get_template_part( 'loop', 'ad_listing' ); ?>
      Replace this with
      Code:
      <?php //get_template_part( 'loop', 'ad_listing' ); ?>
      <!-- FEATURED CAT EDIT -->
      <?php  
      				wp_reset_query();
      				$paged = 0;
      				query_posts(array('post__in'=>get_option('sticky_posts'),'post_type' => APP_POST_TYPE, APP_TAX_CAT => $term->slug, 'paged' => $paged, posts_per_page=>5, orderby => 'rand')); 
      				global $postisfeatured;
      $featurePostArray = array();
      global $featurePostArray;
      				$postisfeatured = "1";
      				get_template_part( 'loop', 'ad_listing' );
      
                      wp_reset_query();
      
      				$paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1;
                   	query_posts(array('post_type' => APP_POST_TYPE, APP_TAX_CAT => $term->slug, 'paged' => $paged));
      				$postisfeatured = "";
      			 	get_template_part( 'loop', 'ad_listing' );
                      wp_reset_query();
      			 ?>
    2. loop-ad_listing.php
      Find
      Code:
      <?php appthemes_before_post(); ?>
      Add below this
      Code:
      <?php 
      global $postisfeatured;
      global $featurePostArray;
      if ($postisfeatured == "1") {
      array_push($featurePostArray,$post->ID);
      } 
      if (in_array($post->ID,$featurePostArray) && $postisfeatured != "1") {
      echo '<div class="hide">';
      }
             ?>
      Find
      Code:
      <?php appthemes_after_endwhile(); ?>
      Replace with
      Code:
      <?php // appthemes_after_endwhile(); ?>
      <?php 
      	if ($postisfeatured != "1"){
      		appthemes_after_endwhile(); 
      		$postisfeatured = "";
      		}
      		?>
    3. style.css

      Add to bottom
      Code:
      .hide {display:none;}


    Support the Author
    Either buy me a beer or if your willing to link to one of my website's PM me (I will update my Signature once they are live, so you can copy the link code from there if you like)

    PLEASE DO NOT ASK FOR SUPPORT IN THIS THREAD - Support Thread here, this is because I will be providing some updates (for searchs and highlighting and I want people to be able to find them.

  2. The Following 3 Users Say Thank You to mossj88 For This Useful Post:

    ismpereira (April 1st, 2012), moko82 (March 3rd, 2013), stilz (October 29th, 2013)

  3. #2
    Thread Starter
    Member mossj88's Avatar
    Join Date
    Feb 2012
    Location
    England
    Posts
    60
    Thanks
    3
    Thanked 9 Times in 7 Posts
    You must be an AppThemes customer and logged in to view this response. Join today!
    To be updated...

    P.S Chive On!

  4. The Following User Says Thank You to mossj88 For This Useful Post:

    ecua (April 1st, 2012)

  5. #3
    samcy's Avatar
    Join Date
    Mar 2012
    Location
    Germany
    Posts
    12,098
    Thanks
    121
    Thanked 1,756 Times in 1,442 Posts
    You must be an AppThemes customer and logged in to view this response. Join today!

  6. #4
    Senior Member ecua's Avatar
    Join Date
    Jan 2012
    Location
    Ecuador - Nederland
    Posts
    113
    Thanks
    8
    Thanked 14 Times in 12 Posts
    You must be an AppThemes customer and logged in to view this response. Join today!

  7. #5
    Amateur fire228's Avatar
    Join Date
    Mar 2012
    Location
    United States
    Posts
    11
    Thanks
    1
    Thanked 2 Times in 1 Post
    You must be an AppThemes customer and logged in to view this response. Join today!

  8. #6
    rivacorretor's Avatar
    Join Date
    Jul 2010
    Location
    Brazil
    Posts
    54
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You must be an AppThemes customer and logged in to view this response. Join today!
    Marcelo/brasil
    gritodeoferta.com.br

  9. #7
    Thread Starter
    Member mossj88's Avatar
    Join Date
    Feb 2012
    Location
    England
    Posts
    60
    Thanks
    3
    Thanked 9 Times in 7 Posts
    You must be an AppThemes customer and logged in to view this response. Join today!
    To be updated...

    P.S Chive On!

  10. #8
    Thread Starter
    Member mossj88's Avatar
    Join Date
    Feb 2012
    Location
    England
    Posts
    60
    Thanks
    3
    Thanked 9 Times in 7 Posts
    You must be an AppThemes customer and logged in to view this response. Join today!
    To be updated...

    P.S Chive On!

  11. #9
    Thread Starter
    Member mossj88's Avatar
    Join Date
    Feb 2012
    Location
    England
    Posts
    60
    Thanks
    3
    Thanked 9 Times in 7 Posts
    You must be an AppThemes customer and logged in to view this response. Join today!
    To be updated...

    P.S Chive On!

  12. #10
    rivacorretor's Avatar
    Join Date
    Jul 2010
    Location
    Brazil
    Posts
    54
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You must be an AppThemes customer and logged in to view this response. Join today!
    Marcelo/brasil
    gritodeoferta.com.br

Page 1 of 4 123 ... LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. highlighted + featured ribbon + top category for featured listing
    By opacity101 in forum ClassiPress General Discussion
    Replies: 19
    Last Post: December 18th, 2012, 06:05 AM
  2. Featured by category
    By servisena in forum Report ClassiPress Bugs
    Replies: 3
    Last Post: November 30th, 2010, 07:54 AM