All Posts in WordPress

How to add even and odd classes to posts

First declare this variable before your while or foreach loop: <?php $j = ''; ?> Then paste this code within the class attribute of your element within the loop: <?php echo (++$j % 2…

Creating Custom Single Post Templates for Specific Category

In your single.php just replace this line: <?php if (have_posts()) : ?> With this one: <?php if ( have_posts() ) { the_post(); rewind_posts(); } if ( in_category(…

How to Create Shortcodes with Atttibutes

If you want to create a button shortcode then just paste this code in your themes functions.php file. //[button title="Visit Site" link="http://jasonellis.ca"] function button_func( $atts ) { …

Use shortcodes in widgets

Just add this line of code to your theme's funtions.php file add_filter('widget_text', 'do_shortcode'); …

Create shortcode WordPress

//[sayhello] function hello_func( $atts ){ return "Hello there!"; } add_shortcode( 'sayhello', 'hello_func' ); …