Skip to main content
Lose spelled 'loose'
Source Link
MrJustin
  • 804
  • 1
  • 8
  • 17

I use the Categories widget on my sidebar(s) and I would like to display a Font Awesome icon next to each category listed in the widget. The icon would be the same for all categories, for now, but I would like to give each category it's own unique icon in the future.

I would like to modify the Categories widget using code in my functions.php file to add the icon by inserting markup like <i class="fa fa-chevron-right"></i> into category's link/anchor element after the category's title. I could accomplish this via CSS, but in doing so I looselose the ability to programmatically determine which icon to display, along with the flexibility for other improvements/changes that I may wish to make in the future.


Basically, I wish to achieve this effect:

Cat 1          >

Cat 2          >

Cat 3          >

(The greater-than symbol '>' represents the icon placement relative to the category title)


I have Font Awesome enqueued in the functions.php file using the wp_enqueue_scripts hook as follows, and it loads and displays the icons perfectly. Note that I do not use any Font Awesome plugin built for WordPress.

/* Enqueue Scripts
-----------------------------------------------------------------*/
add_action( 'wp_enqueue_scripts', 'essentials_enqueue_scripts' );
function essentials_enqueue_scripts() {
    /* jQuery */
    wp_enqueue_script('jquery');
    wp_enqueue_script( 'jquery_ui', "http" . ($_SERVER['SERVER_PORT'] == 443 ? "s" : "") . "://ajax.googleapis.com/ajax/libs/jqueryui/2.0.3/jquery-ui.min.js", false, null);
    wp_enqueue_script( 'waypoints', get_template_directory_uri() . '/js/waypoints.min.js');
    wp_enqueue_script( 'essentials_main', get_template_directory_uri() . '/js/essentials_main.js', array(), '1.0.0', true );
    wp_enqueue_script( 'essentials_show_stuff', get_template_directory_uri() . '/js/essentials_show_stuff.js', array(), '1.0.0', true );
    /* Google Fonts */
    wp_register_style('GoogleFonts','http://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700,800|Bad+Script');
    wp_enqueue_style( 'GoogleFonts');
    /* Font Awesome Fonts */
    wp_register_style('Font Awesome','//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css');
    wp_enqueue_style( 'Font Awesome'); 
}

Despite my best research efforts, I was unable to find a solution to modify the categories widget.

I use the Categories widget on my sidebar(s) and I would like to display a Font Awesome icon next to each category listed in the widget. The icon would be the same for all categories, for now, but I would like to give each category it's own unique icon in the future.

I would like to modify the Categories widget using code in my functions.php file to add the icon by inserting markup like <i class="fa fa-chevron-right"></i> into category's link/anchor element after the category's title. I could accomplish this via CSS, but in doing so I loose the ability to programmatically determine which icon to display, along with the flexibility for other improvements/changes that I may wish to make in the future.


Basically, I wish to achieve this effect:

Cat 1          >

Cat 2          >

Cat 3          >

(The greater-than symbol '>' represents the icon placement relative to the category title)


I have Font Awesome enqueued in the functions.php file using the wp_enqueue_scripts hook as follows, and it loads and displays the icons perfectly. Note that I do not use any Font Awesome plugin built for WordPress.

/* Enqueue Scripts
-----------------------------------------------------------------*/
add_action( 'wp_enqueue_scripts', 'essentials_enqueue_scripts' );
function essentials_enqueue_scripts() {
    /* jQuery */
    wp_enqueue_script('jquery');
    wp_enqueue_script( 'jquery_ui', "http" . ($_SERVER['SERVER_PORT'] == 443 ? "s" : "") . "://ajax.googleapis.com/ajax/libs/jqueryui/2.0.3/jquery-ui.min.js", false, null);
    wp_enqueue_script( 'waypoints', get_template_directory_uri() . '/js/waypoints.min.js');
    wp_enqueue_script( 'essentials_main', get_template_directory_uri() . '/js/essentials_main.js', array(), '1.0.0', true );
    wp_enqueue_script( 'essentials_show_stuff', get_template_directory_uri() . '/js/essentials_show_stuff.js', array(), '1.0.0', true );
    /* Google Fonts */
    wp_register_style('GoogleFonts','http://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700,800|Bad+Script');
    wp_enqueue_style( 'GoogleFonts');
    /* Font Awesome Fonts */
    wp_register_style('Font Awesome','//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css');
    wp_enqueue_style( 'Font Awesome'); 
}

Despite my best research efforts, I was unable to find a solution to modify the categories widget.

I use the Categories widget on my sidebar(s) and I would like to display a Font Awesome icon next to each category listed in the widget. The icon would be the same for all categories, for now, but I would like to give each category it's own unique icon in the future.

I would like to modify the Categories widget using code in my functions.php file to add the icon by inserting markup like <i class="fa fa-chevron-right"></i> into category's link/anchor element after the category's title. I could accomplish this via CSS, but in doing so I lose the ability to programmatically determine which icon to display, along with the flexibility for other improvements/changes that I may wish to make in the future.


Basically, I wish to achieve this effect:

Cat 1          >

Cat 2          >

Cat 3          >

(The greater-than symbol '>' represents the icon placement relative to the category title)


I have Font Awesome enqueued in the functions.php file using the wp_enqueue_scripts hook as follows, and it loads and displays the icons perfectly. Note that I do not use any Font Awesome plugin built for WordPress.

/* Enqueue Scripts
-----------------------------------------------------------------*/
add_action( 'wp_enqueue_scripts', 'essentials_enqueue_scripts' );
function essentials_enqueue_scripts() {
    /* jQuery */
    wp_enqueue_script('jquery');
    wp_enqueue_script( 'jquery_ui', "http" . ($_SERVER['SERVER_PORT'] == 443 ? "s" : "") . "://ajax.googleapis.com/ajax/libs/jqueryui/2.0.3/jquery-ui.min.js", false, null);
    wp_enqueue_script( 'waypoints', get_template_directory_uri() . '/js/waypoints.min.js');
    wp_enqueue_script( 'essentials_main', get_template_directory_uri() . '/js/essentials_main.js', array(), '1.0.0', true );
    wp_enqueue_script( 'essentials_show_stuff', get_template_directory_uri() . '/js/essentials_show_stuff.js', array(), '1.0.0', true );
    /* Google Fonts */
    wp_register_style('GoogleFonts','http://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700,800|Bad+Script');
    wp_enqueue_style( 'GoogleFonts');
    /* Font Awesome Fonts */
    wp_register_style('Font Awesome','//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css');
    wp_enqueue_style( 'Font Awesome'); 
}

Despite my best research efforts, I was unable to find a solution to modify the categories widget.

Clarified author's intent & "distilled the essence of the question." Removed many instances of unnecessary repetition. Re-titled for more precision. Removed author's meta-statement about relevance - author's edits made it relevant. Added link to relevant resource. Improved formatting for readibility
Source Link

Adding font awesome Programmatically Add Font-Awesome Icons to sidebar(s)Category Widget

I'm having troubles here. II use the Categories widget on my sidebar(s) and I would like to be able to usedisplay a font awesome icon on itFont Awesome icon next to each category listed in the widget. The icon would be the same iconfor all categories, for now, andbut I would modify it laterlike to makegive each category it's own unique icon in the categories have separate iconsfuture.

I would like to modify the Categories widget withinusing code in my functions.phpfunctions.php file to inject/insert anadd the icon by inserting markup like <i class="fa fa-chevron-right"></i> inside theinto category's link, but after/anchor element after the textcategory's title. I am able to do itcould accomplish this via style.cssCSS, but I feel that I am going to be limited to what I can do in the future.

In the future,doing so I want to be ableloose the ability to set anprogrammatically determine which icon via the categories section to each individual categorydisplay, which would be displayed onalong with the sidebar. I do not reallyflexibility for other improvements/changes that I may wish to have to put 25 lines of code into my CSS to displaymake in the different icons. I would be fine doing an array or such within my functions.php filefuture.

Basically

 

Cat 1 >Basically, I wish to achieve this effect:

Cat 2 >

Cat 1          >

Cat 2          >

Cat 3          >

Cat 3 >(The greater-than symbol '>' represents the icon placement relative to the category title)

The > is the icon

 

I have Font Awesome enqueued in the functions.php file using the wp_enqueue_scripts hook as follows, and it calls uploads and displays the icons perfectly. I Note that I do not use any Font Awesome plugin built for WordPress.

This is how I enqueue Font Awesome.

I had doneDespite my best research efforts, and thatI was it. I wasn't ableunable to find a solution on my own to modify the categories widget. I have learned through this, mainly the remove_filter and preg_replace.

From my understanding, not everyone see's this question as 'WordPress Specific', but if I tried to place this on StackOverflow.com, I feel that they would refer to me to here :)

Adding font awesome to sidebar(s)

I'm having troubles here. I use the Categories widget on my sidebar(s) and I would like to be able to use a font awesome icon on it. The icon would be the same icon for now, and I would modify it later to make the categories have separate icons.

I would like to modify the Categories widget within my functions.php file to inject/insert an icon like <i class="fa fa-chevron-right"></i> inside the link, but after the text. I am able to do it via style.css, but I feel that I am going to be limited to what I can do in the future.

In the future, I want to be able to set an icon via the categories section to each individual category, which would be displayed on the sidebar. I do not really wish to have to put 25 lines of code into my CSS to display the different icons. I would be fine doing an array or such within my functions.php file.

Basically

Cat 1 >

Cat 2 >

Cat 3 >

The > is the icon

I have Font Awesome enqueued in the functions.php file and it calls up and displays icons perfectly. I do not use any Font Awesome plugin built for WordPress.

This is how I enqueue Font Awesome.

I had done research, and that was it. I wasn't able to find a solution on my own to modify the categories widget. I have learned through this, mainly the remove_filter and preg_replace.

From my understanding, not everyone see's this question as 'WordPress Specific', but if I tried to place this on StackOverflow.com, I feel that they would refer to me to here :)

Programmatically Add Font-Awesome Icons to Category Widget

I use the Categories widget on my sidebar(s) and I would like to display a Font Awesome icon next to each category listed in the widget. The icon would be the same for all categories, for now, but I would like to give each category it's own unique icon in the future.

I would like to modify the Categories widget using code in my functions.php file to add the icon by inserting markup like <i class="fa fa-chevron-right"></i> into category's link/anchor element after the category's title. I could accomplish this via CSS, but in doing so I loose the ability to programmatically determine which icon to display, along with the flexibility for other improvements/changes that I may wish to make in the future.

 

Basically, I wish to achieve this effect:

Cat 1          >

Cat 2          >

Cat 3          >

(The greater-than symbol '>' represents the icon placement relative to the category title)

 

I have Font Awesome enqueued in the functions.php file using the wp_enqueue_scripts hook as follows, and it loads and displays the icons perfectly. Note that I do not use any Font Awesome plugin built for WordPress.

Despite my best research efforts, I was unable to find a solution to modify the categories widget.

deleted 281 characters in body
Source Link
MrJustin
  • 804
  • 1
  • 8
  • 17

I'm having troubles here. I use the Categories widget on my sidebar(s) and I would like to be able to use a font awesome icon on it. The icon would be the same icon (just an arrow pointingfor now, and I would modify it later to make the right).categories have separate icons.

I really don't wantwould like to re-inventmodify the wheel here, so if I could just pop something intoCategories widget within my themes function.phpfunctions.php file to inject/insert an icon like <i class="fa fa-chevron-right"></i> inside the link, but after the text. I am able to do it via style.css, but I feel that wouldI am going to be great (this is a custom theme of minelimited to what I can do in the future.) I don't

In the future, I want to completely havebe able to rebuildset an icon via the Widget itselfcategories section to each individual category, if that's what mustwhich would be done, I can easily do thatdisplayed on the sidebar. I would prefer justdo not really wish to pop a littlehave to put 25 lines of code into my CSS to display the functionsdifferent icons. I would be fine doing an array or such within my functions.php file.

BasicallyBasically

Cat 3 >

The > is the icon

---Edit---

Before anyone says use a background image, I do not want to do that. I would like it to be physical.

---Edit for Daniel---

  <ul>
        <li class="cat-item cat-item-7"><a href="#" title="text">News</a></li>
        <li class="cat-item cat-item-11"><a href="#" title="text">jQuery</a></li>
        <li class="cat-item cat-item-1"><a href="#" title="text">Plugin Updates</a></li>
        <li class="cat-item cat-item-3"><a href="#" title="text">Theme Updates</a></li>
  </ul>

This is the output of the HTML.

--EDIT--The > is the icon

Since I was getting down voted, and someone asked for more details.

This is WordPress specific due to me wanting to customize WordPress categories via the FUNCTIONS.PHP file. I would have coded another Widget if I needed to, but wanted to just pop something intoFont Awesome enqueued in the functions.phpfunctions.php file and it calls up and displays icons perfectly. I wasn't lookingdo not use any Font Awesome plugin built for a CSS route as this will be more customizable in the futureWordPress.

I had done research, and that was it. I wasn't able to find a solution on my own to modify the categories widget. I have learned through this, mainly the remove_filter and preg_replace.

From my understanding, not everyone see's this question as 'WordPress Specific', but if I tried to place this on StackOverflow.com, I feel that they would refer to me to here :)

I'm having troubles here. I use the Categories widget on my sidebar(s) and I would like to be able to use a font awesome icon on it. The icon would be the same icon (just an arrow pointing to the right)..

I really don't want to re-invent the wheel here, so if I could just pop something into my themes function.php file that would be great (this is a custom theme of mine.) I don't want to completely have to rebuild the Widget itself, if that's what must be done, I can easily do that. I would prefer just to pop a little code into the functions.

Basically

Cat 3 >

The > is the icon

---Edit---

Before anyone says use a background image, I do not want to do that. I would like it to be physical.

---Edit for Daniel---

  <ul>
        <li class="cat-item cat-item-7"><a href="#" title="text">News</a></li>
        <li class="cat-item cat-item-11"><a href="#" title="text">jQuery</a></li>
        <li class="cat-item cat-item-1"><a href="#" title="text">Plugin Updates</a></li>
        <li class="cat-item cat-item-3"><a href="#" title="text">Theme Updates</a></li>
  </ul>

This is the output of the HTML.

--EDIT--

Since I was getting down voted, and someone asked for more details.

This is WordPress specific due to me wanting to customize WordPress categories via the FUNCTIONS.PHP file. I would have coded another Widget if I needed to, but wanted to just pop something into the functions.php file. I wasn't looking for a CSS route as this will be more customizable in the future.

I had done research, and that was it. I wasn't able to find a solution on my own to modify the categories widget. I have learned through this, mainly the remove_filter and preg_replace.

I'm having troubles here. I use the Categories widget on my sidebar(s) and I would like to be able to use a font awesome icon on it. The icon would be the same icon for now, and I would modify it later to make the categories have separate icons.

I would like to modify the Categories widget within my functions.php file to inject/insert an icon like <i class="fa fa-chevron-right"></i> inside the link, but after the text. I am able to do it via style.css, but I feel that I am going to be limited to what I can do in the future.

In the future, I want to be able to set an icon via the categories section to each individual category, which would be displayed on the sidebar. I do not really wish to have to put 25 lines of code into my CSS to display the different icons. I would be fine doing an array or such within my functions.php file.

Basically

Cat 3 >

The > is the icon

I have Font Awesome enqueued in the functions.php file and it calls up and displays icons perfectly. I do not use any Font Awesome plugin built for WordPress.

I had done research, and that was it. I wasn't able to find a solution on my own to modify the categories widget. I have learned through this, mainly the remove_filter and preg_replace.

From my understanding, not everyone see's this question as 'WordPress Specific', but if I tried to place this on StackOverflow.com, I feel that they would refer to me to here :)

added 1748 characters in body
Source Link
MrJustin
  • 804
  • 1
  • 8
  • 17
Loading
Notice removed Draw attention by MrJustin
Bounty Ended with birgire's answer chosen by MrJustin
Notice added Draw attention by MrJustin
Bounty Started worth 100 reputation by MrJustin
Tweeted twitter.com/#!/StackWordPress/status/418737984331329536
added 445 characters in body
Source Link
MrJustin
  • 804
  • 1
  • 8
  • 17
Loading
Source Link
MrJustin
  • 804
  • 1
  • 8
  • 17
Loading