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

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

This topic is: not resolved

This topic contains 12 replies, has 2 voices, and was last updated by  rfmeier 1 year, 5 months ago.

Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #44243

    kaboodle
    Participant
    Post count: 7

    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
    #44252

    rfmeier
    Participant
    Post count: 603

    Hello,

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


    #44257

    kaboodle
    Participant
    Post count: 7

    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!

    #44258

    rfmeier
    Participant
    Post count: 603

    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.


    #44259

    kaboodle
    Participant
    Post count: 7

    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?

    #44290

    rfmeier
    Participant
    Post count: 603

    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.


    #44295

    kaboodle
    Participant
    Post count: 7

    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/

    #44296

    rfmeier
    Participant
    Post count: 603

    Hello,

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


    #44297

    kaboodle
    Participant
    Post count: 7

    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 */

    #44299

    kaboodle
    Participant
    Post count: 7

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

    #44300

    rfmeier
    Participant
    Post count: 603

    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 rfmeier@gmail.com


    #44305

    kaboodle
    Participant
    Post count: 7

    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

    #44309

    rfmeier
    Participant
    Post count: 603
    This reply has been marked as private.
Viewing 13 posts - 1 through 13 (of 13 total)

You must be logged in to reply to this topic.