Category image links

Solved5.98K viewsGeneral
1

Hi,

Wondering, is it possible to make the images for categories also link to that category? Otherwise, use has to click category title.

Thanks,

1

Hi, please go to wp-content/plugins/categories-for-anspress/theme/categories.php and replace line 28:

<?php echo ap_get_category_image($category->term_id); ?>

with this:

<a class=”ap-cat-image” target=”_blank” href=”<?php echo get_category_link( $category );?>”><?php echo ap_get_category_image($category->term_id); ?></a>

and line 32:

<a class=”term-title” href=”<?php echo get_category_link( $category );?>”>

with this:

<a class=”term-title” target=”_blank” href=”<?php echo get_category_link( $category );?>”>

then go to wp-content/plugins/categories-for-anspress/categories-widget.php and replace lines 34 and 35:

<a class=”ap-cat-image” href=”<?php echo get_category_link( $category );?>”><?php echo ap_get_category_image($category->term_id); ?></a>
<a class=”ap-cat-wid-title” href=”<?php echo get_category_link( $category );?>”>

with this:

<a class=”ap-cat-image” target=”_blank” href=”<?php echo get_category_link( $category );?>”><?php echo ap_get_category_image($category->term_id); ?></a>
<a class=”ap-cat-wid-title” target=”_blank” href=”<?php echo get_category_link( $category );?>”>

GOOD LUCK

Almost works! But it appends the link to existing URL… so it refreshes page as: https://n4bb.com/forums/categories/“https://n4bb.com/forums/category/general-tech-discussion/”

Wait, nvm it worked!! When I copied the code the ” were messed up in my Brackets editor lol. Thank you!

Add ( target=”_blank” ) before ( href ) in all places you want.

I updated my answer, please replace codes and then vote up & select my answer 🙂

Yes of course! 🙂

0

getting this error
Parse error: syntax error, unexpected ‘AnsPress_Category_Widget’ (T_STRING) on

wp-content/plugins/categories-for-anspress/categories-widget.php on line 1