Hi,
You can use this code in loop.php file like this: http://screencast.com/t/lI3oL0TV0O6
Replace the ‘207’ with your category ID in which you would want the block to be showed. Also use the do_shortcode() function to add the block widget as you like, just replace the short-code from my example with your own.
Hope this helps!
Here is the code I used:
if (is_category('226')) {
echo do_shortcode('[vc_row][vc_column width="1/1"][td_block9 sort="random_posts" limit="5"][/vc_column][/vc_row]');
}
Thanks
Thansk Lucian. I’ve tried placing that code in an advanced widget but i get some errors appear. Do i need to place that code in a certain file to get it to appear in the Newspaper Default widget? Sorry for the no doubt very basic question! PHP isn’t my strong point!
Thanks.
Dave
Hi,
Please use http://pastebin.com/ to send me the code from loop.php file so I can check it, should work fine, I have tested this, you just need to add this condition in loop.php file and also add your widget short-code into the function and the category ID on which you want the widget to be shown.
Thanks
Thanks Lucian. I may be doing something wrong. What should the widget code look like?
Loo.php attached. At the moment something odd happens at the bottom of the competitions section where it’s loading another section.
You can see what I mean here – Under the comps it’s loaded some random posts from i’ve no idea where! : http://www.heyuguys.com/competitions/
D
Hi,
You have to replace this shortcode: http://screencast.com/t/aU7trBlMoEe with your own desired block shortcode then your block will appear there.
Thanks
Hi,
Use page builder: http://screencast.com/t/PfhCn9Y0hzX and customize it like you want, then switch to classic mode view, get the shortcode for it: http://screencast.com/t/NX0r1MLZnfaE and replace the one from here: http://screencast.com/t/aU7trBlMoEe
Thanks
Perfect, thanks so much and sorry for asking silly questions. You’ve been awesome.
So I’ve got the widget in, but for some reason nothing on it is clickable?!
http://www.heyuguys.com/competitions/
D
-
This reply was modified 11 years by
daveszt. Reason: Updated
Sorry if i wasnt clear. Go to the competitions section,
http://www.heyuguys.com/competitions/
See the new widget on the right hand side of the site which loads competitions in that section. That widget is not clickable.
http://www.heyuguys.com/widget.jpg
D
Hi,
You don’t need to add the block widget into an text widget like you did here: http://screencast.com/t/Hn48Ivn1S9VI
You just add the block into the sidebar and customize it, like this: http://screencast.com/t/56Uk7BaDor
Make sure you add the block the right way.
Thanks
Hi,
If you need that widget to appear only in that category follow this steps:
First remove the code I provided before to add an widget using short-codes, this code adds this block from the bottom of the category page: http://screencast.com/t/TH9vXkb1
After this create a new sidebar like this: http://screencast.com/t/qDp0rEFACe
Then go to appearance > widgets and add the block widget you want to the newly created sidebar, like this: http://screencast.com/t/bBb3sqdpzIS
After you have done all this go to theme panel > categories to the category you want to add the sidebar at and select the new created sidebar for that category only, like this: http://screencast.com/t/kwyygatOZ
Should work fine after this: http://screencast.com/t/J24VaBjRS
Thanks