There is a page template called “All Bookmarks” for displaying all links grouped by category. I want to modify it 2 ways:
- each category of links should be collapsible/expandable by clicking on the category header
- the template should accept a list of categories to either include or exclude
For the collapsible part, assumably I need only add a class to each category header so that my jQuery code can affect them. For the category limiting, assumably I need a way to pass parametres to the template. However, I’m a complete noob to WP and I don’t know
- where to put the jQuery code
- whether to add the class to the template, or to create a new template
- where to store a new template so that it will be available to Pages
- if templates can take parametres or if a template needs to refer to a custom PHP function
- where to store custom PHP functions
I’ve been wandering around WordPress.org for a while becoming more and more frustrated. I’d appreciate it if someone could address the above questions and perhaps point me to a good explanation of WP code structure.
Thanks!
Version: WP 3.1
Theme: Suffusion 3.7.7
Rather than modifying the template, since you’re going to need jQuery anyway, you can do this..
Add to the functions.php
Or create a new folder in the
wp-content/plugins/
folder, create a file inside the new folder, eg. blogroll-plugin.php, and add the following.The function will basically enqueue in the script whenever a page is loaded with the bookmarks template attached to it. jQuery is set as a dependancy for the script, so there’s no need to load that seperately.
Create a file in the theme(or plugin) folder and call it blogroll-toggle.js, then place the following code into that file.
The jQuery is untested, but it should work(i’ve done toggles dozens of times).
NOTE: If using as a plugin, remember to activate it like you would any other plugin.
Any problems with the code, let me know. 🙂