Skip to main content

Timeline for How do I make a shortcode?

Current License: CC BY-SA 3.0

5 events
when toggle format what by license comment
Nov 27, 2013 at 20:17 comment added Jon Furry You dont need to put it in caps, I just did that so you could see what to replace. Simply copy the code you've got and paste it where it says //your code here (which it looks like you've done). Then copy the whole function and put it in your themes functions.php file. Then you can use your shortcode in whatever template/page/post you want.
Nov 27, 2013 at 19:42 comment added Katy W function CATEGORY_LIST_shortcode() {$args = array( 'taxonomy' => 'product_cat' ); $terms = get_terms('product_cat', $args); $count = count($terms); $i=0; if ($count > 0) { $cape_list = '<p class="my_term-archive">'; foreach ($terms as $term) { $i++; $term_list .= '<a href="/term-base/' . $term->slug . '" title="' . sprintf(__('View all post filed under %s', 'my_localization_domain'), $term->name) . '">' . $term->name . '</a>'; if ($count != $i) $term_list .= ' &middot; '; else $term_list .= '</p>'; } echo $term_list; }
Nov 27, 2013 at 19:41 comment added Katy W So, like this? And do I put this in the custom.css? add_shortcode('CATEGORY_LIST', 'CATEGORY_LIST_shortcode'); <to be ctd>
Nov 27, 2013 at 9:39 comment added Michael in your CODE HERE section, make sure not to use any function that echos the output.
Nov 27, 2013 at 3:30 history answered Jon Furry CC BY-SA 3.0