• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

Backcountry: Make Widget Category Titles on Front Page "Clickable" to Category

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Archived Forums › Design Tips and Tricks › Backcountry: Make Widget Category Titles on Front Page "Clickable" to Category

This topic is: not resolved

Tagged: backcountry, widget titles

  • This topic has 12 replies, 2 voices, and was last updated 12 years, 7 months ago by rfmeier.
Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • June 5, 2013 at 5:23 pm #44243
    kaboodle
    Member

    Everything the latest version including Genesis 2.0 (which works like a champ BTW! Nice work guys!).

    http://www.thehealthycookingblog.com

    Here's what I'm trying to do:  Home Top Left, Right, Bottom Widget Titles example:  Arthritis -- I would like the title to be clickable to the selected category.

    Any thoughts?

     

    Thanks

    http://www.thehealthycookingblog.com
    June 5, 2013 at 7:12 pm #44252
    rfmeier
    Member

    Hello,

    I am guessing some custom code will have to hook the widget titles and create a link. What widget are you using?


    Ryan Meier – Twitter

    June 5, 2013 at 7:45 pm #44257
    kaboodle
    Member

    just the Genesis Featured Posts, nice and simple.  If it were a plugin I'd edit it right in there, but I'm not exactly sure where to go in the framework to fool around, and not sure that I really want to wade into those waters with out at least a point in the right direction if you know what I mean!

    June 5, 2013 at 8:12 pm #44258
    rfmeier
    Member

    I threw this snippet together. It hooks the WordPress 'widget_title' filter.

    Note, this will create a category link on all pages using this widget for all pages. If you just want it on the home page you can check the page.

    I hope this helps.


    Ryan Meier – Twitter

    June 5, 2013 at 8:24 pm #44259
    kaboodle
    Member

    you rock!  so I want to throw this into Genesis Hooks right, with 'widget title' and then create a .php file using your snippet and load it up into the theme folder, is that correct?

    June 6, 2013 at 7:19 am #44290
    rfmeier
    Member

    All you have to do is paste that code into your theme's function.php file.

     

    Let me know if you run into any issues.


    Ryan Meier – Twitter

    June 6, 2013 at 7:37 am #44295
    kaboodle
    Member

    just did it, got this Warning: Missing argument 2 for custom_widget_title() in /home/goodcook/public_html/wp-content/themes/backcountry/functions.php on line 72

    http://thehealthycookingblog.com/

    June 6, 2013 at 7:40 am #44296
    rfmeier
    Member

    Hello,

    Arg. I updated the code above. It will now account for variables not being passed. Sorry about that.


    Ryan Meier – Twitter

    June 6, 2013 at 7:42 am #44297
    kaboodle
    Member

    this is the whole shadoobie.  Line 72 according to PSDPad would be

    function custom_widget_title( $title, $instance, $id_base ){

     

    <?php
    /** Start the engine */
    require_once( get_template_directory() . '/lib/init.php' );

    /** Create additional color style options */
    add_theme_support( 'genesis-style-selector', array( 'backcountry-blue' => 'Blue', 'backcountry-green' => 'Green', 'backcountry-red' => 'Red' ) );

    /** Child theme (do not remove) */
    define( 'CHILD_THEME_NAME', 'Backcountry Child Theme' );
    define( 'CHILD_THEME_URL', 'http://www.studiopress.com/themes/backcountry' );

    $content_width = apply_filters( 'content_width', 470, 400, 910 );

    /** Add new image sizes */
    add_image_size( 'home-bottom', 170, 90, TRUE );
    add_image_size( 'home-middle', 265, 150, TRUE );
    add_image_size( 'home-mini', 50, 50, TRUE );

    /** Add support for custom background */
    add_custom_background();

    /** Add support for custom header */
    add_theme_support( 'genesis-custom-header', array( 'width' => 960, 'height' => 120 ) );

    /** Reposition the primary navigation */
    remove_action( 'genesis_after_header', 'genesis_do_nav' );
    add_action( 'genesis_before_header', 'genesis_do_nav' );

    /** Add description to secondary navigation */
    add_filter( 'walker_nav_menu_start_el', 'add_description', 10, 4 );
    function add_description( $item_output, $item, $depth, $args ) {

    $args = (array) $args;

    if ( $args['theme_location'] != 'primary' )  {
    return preg_replace( '/(<a.*?>[^<]*?)</', '$1' . "<span class=\"menu-description\">{$item->post_content}</span><", $item_output );
    }
    else {
    return $item_output;
    }

    }

    /** Add home top section to homepage */
    add_action( 'genesis_before_content_sidebar_wrap', 'backcountry_home_top' );
    function backcountry_home_top() {

    if ( is_front_page() && is_active_sidebar( 'home-top' ) ) {
    echo '<div id="home-top">';
    dynamic_sidebar( 'home-top' );
    echo '</div><!-- end #home-top -->';
    }

    }

    add_filter( 'widget_title', 'custom_widget_title', 10, 3 );
    /**
    * Callback for WordPress 'widget_title' filter.
    *
    * Create a link for the title of the Genesis Featured Widget if a category is
    * specified.
    *
    * @package WordPress
    * @category Widget
    * @author Ryan Meier http://www.rfmeier.net
    *
    * @param string $title The widget title
    * @param object $instance The instance of the current widget
    * @param string $id_base the base id
    * @return string $title The widget title
    */
    function custom_widget_title( $title, $instance, $id_base ){
    // if not the featured image post, return title
    if( 'featured-post' != $id_base )
    return $title;
    // if the instance does not specify a category, return title
    if( empty( $instance['posts_cat'] ) )
    return $title;
    // get the category link from the id
    $category_link = get_category_link( $instance['posts_cat'] );
    // get the category name from the id
    $category_name = get_the_category_by_ID( $instance['posts_cat'] );
    // build the category link
    $title_link = sprintf( '<a href="%s" title="%s">%s</a>',
    esc_url( $category_link ),
    esc_attr( $category_name ),
    esc_html( $title ) );
    // return the category link title
    return $title_link;
    }

    /** Customize the post info function */
    add_filter( 'genesis_post_info', 'backcountry_post_info_filter' );
    function backcountry_post_info_filter( $post_info ) {

    return '[post_date] by [post_author_posts_link] &middot; [post_comments] [post_edit]';

    }

    /** Customize the post meta function */
    add_filter( 'genesis_post_meta', 'backcountry_post_meta_filter' );
    function backcountry_post_meta_filter( $post_meta ) {

    return '[post_categories before="Filed Under: "] &middot; [post_tags before="Tagged: "]';

    }

    /** Add after post ad section */
    add_action( 'genesis_after_post_content', 'backcountry_after_post_ad', 9 );
    function backcountry_after_post_ad() {

    if ( is_single() && is_active_sidebar( 'after-post-ad' ) ) {
    echo '<div class="after-post-ad">';
    dynamic_sidebar( 'after-post-ad' );
    echo '</div><!-- end .after-post-ad -->';
    }

    }

    /** Add support for 3-column footer widgets */
    add_theme_support( 'genesis-footer-widgets', 4 );

    /** Register widget areas */
    genesis_register_sidebar( array(
    'id'            => 'home-top',
    'name'            => __( 'Home Top', 'backcountry' ),
    'description'    => __( 'This is the home top section.', 'backcountry' ),
    ) );
    genesis_register_sidebar( array(
    'id'            => 'home-left',
    'name'            => __( 'Home Left', 'backcountry' ),
    'description'    => __( 'This is the home left section.', 'backcountry' ),
    ) );
    genesis_register_sidebar( array(
    'id'            => 'home-right',
    'name'            => __( 'Home Right', 'backcountry' ),
    'description'    => __( 'This is the home right section.', 'backcountry' ),
    ) );
    genesis_register_sidebar( array(
    'id'            => 'home-bottom',
    'name'            => __( 'Home Bottom', 'backcountry' ),
    'description'    => __( 'This is the home bottom section.', 'backcountry' ),
    ) );
    genesis_register_sidebar( array(
    'id'            => 'after-post-ad',
    'name'            => __( 'After Post Ad', 'magazine' ),
    'description'    => __( 'This is the after post ad section.', 'backcountry' ),
    ) );/* CSS Document */

    June 6, 2013 at 7:44 am #44299
    kaboodle
    Member

    like a charm man, can I send you some loot when she pays me for your help?

    June 6, 2013 at 7:46 am #44300
    rfmeier
    Member

    I am glad I could help. Sorry about the error before, I assumed all the variables would be passed. I am completely open to donations if you feel up to it.

    You can reach me at [email protected]


    Ryan Meier – Twitter

    June 6, 2013 at 8:01 am #44305
    kaboodle
    Member

    As soon as she pays up, and she's good about it, I'll get you some loot (just got clobbered yesterday on Child Support -- they cleaned me out!).  In the meantime, how can I give you some love with some social signals, etc.

    Chris  -- email me your paypal address please

    June 6, 2013 at 8:11 am #44309
    rfmeier
    Member
    This reply has been marked as private.
  • Author
    Posts
Viewing 13 posts - 1 through 13 (of 13 total)
  • The forum ‘Design Tips and Tricks’ is closed to new topics and replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2026 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble