BNS Featured Category
[resolved] How to make header title as link to category? (5 posts)

  1. frengerr
    Posted 4 years ago #


    How can I modify the plugin so that the widget's header title is a link that brings me to the category page?

    Thank you!


  2. Edward Caissie
    Theme Review Admin, The JellyBeen Man
    Plugin Author

    Posted 4 years ago #

    First off, make a back-up of the plugin ... just in case.

    Next, you will be looking at this line of code:
    echo $before_title . '<span class="bnsfc-cat-class-' . $cat_choice_class . '">' . $title . '</span>' . $after_title;

    The key is the $title which will need to be wrapped in an <a href=> construct along the lines of:
    <a href="<?php get_category_link( $cat_choice ); ?>">$title</a>

    The above is untested (and the reason I recommended the backup first); it will likely cause a 404 result if more than one category is used in the widget instance; and, will be over-written when version 2.0 of the plugin is released in the near future. Also to note, the entire code line will need to be re-written as the echo will no longer produce the correct results.

    I do like the idea, and will make a note to review it further for possible inclusion in future releases of the plugin, in the meantime keep track of your changes in case it is not included.

  3. frengerr
    Posted 4 years ago #

    Thank for replying! Now the title is as link but the link in itself doesn't work.

    echo $before_title . '<span class="bnsfc-cat-class-' . $cat_choice_class . '">">' . $title . '</span>' . $after_title;

    Am I missing something?

    Now the link goes to: mysite.com/<?php%20get_category_link(%20$cat_choice%20);%20?>

  4. Edward Caissie
    Theme Review Admin, The JellyBeen Man
    Plugin Author

    Posted 4 years ago #

    Use this code as a replacement of the original echo line:

    echo $before_title . '<span class="bnsfc-cat-class-' . $cat_choice_class . '"><a href="' . get_category_link( $cat_choice ) . '">' . $title . '</a></span>' . $after_title;

    Again, the same conditions apply but this was quickly tested in a local environment and appears to work at first glance.

  5. frengerr
    Posted 4 years ago #

    Ok, thank, fixed!

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • BNS Featured Category
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic