Forum breadcrumbs – You are here:Asgaros Support ForumSupportSHORTCODE IF CATEGORY
Please or Register to create posts and topics.

SHORTCODE IF CATEGORY

Hello Asgaros

I was wondering if there is a way show a certain shortcode in a widget if category “if” is met

Steve

Hello,

can you give some more details about what exactly you plan to do?

KryptoDigger has reacted to this post.
KryptoDigger
If you want to support the development of Asgaros Forum, you can leave a good review or donate. Thank you very much!

Lets say the open category is “Bitcoin” in text widget or html widget I would like to show a Bitcoin graph.

Lets say the open category is “Digibyte” in text widget or html widget I would like to show a Digibyte graph.

I have the graphs. Just want to know if this is possible and if you could point me in the right direction on how to find info on this

If you want to implement this with your own PHP-logic, you can access the ID of the current category ID with this code:

global $asgarosforum;

if ($asgarosforum->current_category == 1) {
  echo 'Show BitCoin Graph ...';
} else if ($asgarosforum->current_category == 2) {
  echo 'Show Ripple Graph ...';
}

 

KryptoDigger has reacted to this post.
KryptoDigger
If you want to support the development of Asgaros Forum, you can leave a good review or donate. Thank you very much!

This was fantastic advice. THANK YOU

I installed a widget called PHP Code Widget   https://en-ca.wordpress.org/plugins/php-code-widget/

I used the below code to do what I needed within the widget it self ….

<?
global $asgarosforum;
if ($asgarosforum->current_category == 53) {
 echo 'BITCOIN';
 echo do_shortcode('[crtools-graph coin="BTC" fiat="USD,EUR"]');
} else if ($asgarosforum->current_category == 54) {
 echo 'ETHEREUM';
 echo do_shortcode('[crtools-graph coin="ETH" fiat="USD,EUR"]');
}
else if ($asgarosforum->current_category == 55) {
 echo 'LITECOIN';
 echo do_shortcode('[crtools-graph coin="LTC" fiat="USD,EUR"]');
}
?>

I totally forgot about do_shortcode function in the shortcodes.php file

You can check the forum out here https://bittalk.ca/home/forums/

Working widget here with in desired category https://bittalk.ca/home/forums/?view=forum&id=3

AGAIN

Thank you for the guidance!!!

 

 

Asgaros has reacted to this post.
Asgaros

I am glad to hear that its working! 🙂

KryptoDigger has reacted to this post.
KryptoDigger
If you want to support the development of Asgaros Forum, you can leave a good review or donate. Thank you very much!