Using CCS in widgets
-
I use the following code for my index page:
[pass list=A~Z] [loop exists type="page" parent=this field=alpha value={ITEM} orderby=name] <strong><span style="font-size: 130%;">{Item}</span></strong> <p></p> [the-loop] [field title-link]<br/ > [/the-loop] <p></p> [/loop] [/pass]I wanted to test putting that into a sidebar, but nothing shows up. I just added a Text wdiget and pasted in that code. Is there something different I need to do? Thanks.
-
In the plugin settings, there is an option to enable shortcodes in the text widget. Could you check if it’s enabled?
If yes, then there might be something else happening. Usually, when it’s not enabled, the shortcodes themselves will show without being run – but in your case, it’s displaying nothing. So it sounds like shortcodes are running but not behaving the same way as in post content.. In that case, could you try a normal basic loop and see if it works as expected?
I figured out the problem and learned something new. I realized that I had parent=this in the code, which should have only worked on the index page, but in fact didn’t work there either, which means the sidebars are rendered separately from the page, and ‘this’ is meaningless. I swapped ‘this’ for the ID of the index page, and it rendered properly.
It’s too long, but really it was just a test. Now I need to figure out if I want the full topic list in the sidebar (perhaps using collapsible sections for each letter), or if I want less information. This is where I’m planning to put most recently updated pages, most recent comments, etc.
Hey, not anything about CCS but I thought I would share a neat piece of HTML I just learned about. As mentioned above, I was looking for a way to create a accordion for each letter so in the sidebar it would have all the topics in the sidebar, but would not be too long. At first I found lots of solutions that used a combination of Javascript and CSS. Turns out HTML5 has a pair of tags that does that without any CSS or Javascript – <details> and <summary>. I don’t know if there’s a way to collapse all the other details sections when one is opened – that would be nice, but either way it’s a super-simple solution. I thus can have a complete list of the hundreds of topics in my sidebar, but start out only using one line for each letter. This is my code:
[pass list=A~Z] [loop exists type="page" parent=1234 field=alpha value={ITEM} orderby=name] <details> <summary><strong><span style="font-size: 130%;">{Item}</span></strong></summary> <div> [the-loop] [field title-link]<br/ > [/the-loop] </div> </details> [/loop] [/pass]It’s a neat trick.
The topic ‘Using CCS in widgets’ is closed to new replies.