Page 1 of 3 123 LastLast
Results 1 to 10 of 21

Thread: Adding stuff (like ribbons!) the SMART way using action hooks

  1. #1
    Thread Starter
    Senior Member cjk123's Avatar
    Join Date
    Apr 2012
    Location
    United States
    Posts
    105
    Thanks
    3
    Thanked 23 Times in 13 Posts

    Adding stuff (like ribbons!) the SMART way using action hooks

    When I was shopping for a classifieds solution, the main reason I picked ClassiPress was because it supported Child Themes and more importantly for me, it supported Hooks and Filters and provides many well placed Hooks throughout it's core code. For those not familiar with Hooks, this is a great way to add, change, or modify pretty much anything you want without touching the core theme files. In fact, all of these changes can be made in a child theme functions.php file and then styled with a child theme style.css. Some of you are copying core files into your child theme and editing them, that's fine, what I'm going to show you though is how to add a ribbon to an ad with a simple function and a few css rules!

    1) If you have not yet created a child theme, create one that has a style.css file, a functions.php file and a folder named images..

    2) Open your functions.php file and add this custom function:

    Code:
    //Add featured listing ribbon
    function aha_featured_ribbon() {
        if(is_sticky($post_ID) == true) echo '<div class="featured-ribbon-red"></div>';
        else echo '';
    }
    add_action('appthemes_before_post_title','aha_featured_ribbon');
    Save it

    3) open style.css and add this:

    Code:
    /* Featured Ribbon */ 
    
    /* First set parent divs to position relative */
    .shadowblock,
    .post-block {
        position: relative;
        }
    
    /* Then style and position your ribbon on listings pages */
    .featured-ribbon-red {
        height: 60px;
        width: 60px;
        position: absolute;
        top: -5px;
        left: -5px;
        z-index: 99px;
        background: url("http://forums.appthemes.com/images/featured-red.png") no-repeat;
        }
    
    /* Now style and position on single ad pages */
    div.shadowblock div.featured-ribbon-red {
        top: 69px;
        left: 12px;
        }
    4) Copy your ribbon into your images folder in your child theme. This one should do the job!

    featured-red.png

    That's it, Would someone buy me a beer please?

  2. The Following 4 Users Say Thank You to cjk123 For This Useful Post:

    chanbraithwaite (May 21st, 2012), coza (April 27th, 2012), jomarkosabel (April 24th, 2012), lucrothe (May 30th, 2012)

  3. #2
    jomarkosabel's Avatar
    Join Date
    Mar 2009
    Location
    Philippines
    Posts
    40,789
    Thanks
    166
    Thanked 3,393 Times in 3,264 Posts
    You must be an AppThemes customer and logged in to view this response. Join today!
    Please help our moderating team work more efficiently by not sending us support questions via PM. You can read more about how AppThemes support works here. However, you can send a PM to follow up and remind me if I missed your support request/thread.

    Thank you and have a nice day.

  4. #3
    Junior Member plink's Avatar
    Join Date
    May 2011
    Location
    Australia
    Posts
    37
    Thanks
    2
    Thanked 1 Time in 1 Post
    You must be an AppThemes customer and logged in to view this response. Join today!

  5. #4
    Member anilkumarkanneboina's Avatar
    Join Date
    Mar 2012
    Location
    India
    Posts
    82
    Thanks
    8
    Thanked 2 Times in 2 Posts
    You must be an AppThemes customer and logged in to view this response. Join today!

  6. #5
    Thread Starter
    Senior Member cjk123's Avatar
    Join Date
    Apr 2012
    Location
    United States
    Posts
    105
    Thanks
    3
    Thanked 23 Times in 13 Posts
    You must be an AppThemes customer and logged in to view this response. Join today!

  7. The Following User Says Thank You to cjk123 For This Useful Post:

    appouser (May 5th, 2012)

  8. #6
    Junior Member plink's Avatar
    Join Date
    May 2011
    Location
    Australia
    Posts
    37
    Thanks
    2
    Thanked 1 Time in 1 Post
    You must be an AppThemes customer and logged in to view this response. Join today!

  9. #7
    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!
    Rolf Hassel (Samcy)

  10. #8
    Junior Member plink's Avatar
    Join Date
    May 2011
    Location
    Australia
    Posts
    37
    Thanks
    2
    Thanked 1 Time in 1 Post
    You must be an AppThemes customer and logged in to view this response. Join today!

  11. #9
    Junior Member plink's Avatar
    Join Date
    May 2011
    Location
    Australia
    Posts
    37
    Thanks
    2
    Thanked 1 Time in 1 Post
    You must be an AppThemes customer and logged in to view this response. Join today!

  12. #10
    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!
    Rolf Hassel (Samcy)

Page 1 of 3 123 LastLast

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Can someone explaine a ABC way for me on Action Hooks
    By TheSyndicate in forum WordPress General Discussion
    Replies: 8
    Last Post: April 23rd, 2012, 10:02 PM
  2. Will the new 1.6 change action hooks?
    By TheSyndicate in forum JobRoller General Discussion
    Replies: 0
    Last Post: April 19th, 2012, 11:00 PM
  3. CLIPPER Just a Simple Clipper website with action hooks
    By TheSyndicate in forum Showcase & Feedback
    Replies: 4
    Last Post: March 20th, 2012, 08:20 AM
  4. What action hooks do you want in Clipper?
    By TheSyndicate in forum Clipper General Discussion
    Replies: 0
    Last Post: March 5th, 2012, 02:19 AM