Add Shortcodes To Sidebar

Since WordPress is php based, in order to use shortcodes on the sidebar or anywhere on the theme, we have to use echo.

<h2><?php echo do_shortcode(‘ catlist categorypage=yes excerpt=yes excerpt_size =255)]’); ?></h2>

This is the shortcodes for catlist to list related posts in the same category on the sidebar for my single.php that I’m designing right now (the right bracket before ‘catlist’ is missing).

  • How To Use WP-PageNavi And WP-CommentNavi Plugins
    I’ve been looking ways to paginate my main page posts list, singles, pages and comments, I couldn’t find any answers until I studied about the plugins from  Lester Chan-GamerZ , among those, WP-PageNavi and WP-CommentNavi, I finally found the way to use them for paginate my pages, posts and comments. This is the way I use them with Mono-lab themes: Flat and PianoBlack. If we’re using WordPress 3.4.2, most of these pagination php are already embedded in the system and called out somewhere in our themes, all we need is to find where to place these plugins codes. For blog main page posts pagination, we need to have excerpts turned on and working. The theme files that need to implement with WP-PageNavi codes are: index.php, archive.php and search.php. For Single Post pagination, by using “next-page” while editing, the theme files that need to implement with WP-PageNavi are: single.php and page.php. MAIN PAGE POSTS LIST PAGINATION WITH EXCERPTS Well, we need to install the plugin WP-PageNavi first, activate it and modify some settings if we want, I only modify “<<” and “>>” with “<< Previous” and “Next >>”      Save “settings” and open “index.php”, “archive.php” and “search.php” to search and replace codes with pagenavi codes. We ...
  • IE8-9 Do Not Wrap Long Text CSS Fix
    Our modified theme has problem with ie 8-9 as always, this time it’s the long text NOT wrapping inside the content body. add =” word-wrap: break-word;” or “word-break:break-all;”  in css at the content. .post_wrap { clear:right; } .post { float:right;width:88%; z-index:3; position:relative; } .post_content { background:#dfffdc; margin:0 38% 0 0; padding:20px 2%;color:#14000;font-size:.9em;word-wrap: break-word;} It’s fixed now.
  • Add Share This Button To WordPress
    I try to avoid loading to many plugins to our WordPress blog, I prefer to add the Share This button manually to our single post (single.php). Add the script to the header.php just before </head> <script type=”text/javascript” src=”//w.sharethis.com/button/buttons.js”></script> Now, add this codes to wherever I want to appear in the single.php. Remove the ‘ both sides of the class. <span ‘class’=”st_sharethis_hcount”></span>
  • Fix Youtube Iframe On Top Of Overlay Modals
    2013-08-27 The new editor from WordPress automatically moves the height and width right after the link which causes the script NOT to work. I have to modify so that it will work as long as the height is set at 315 px as default with youtube HD. Now it will work with the new editor. If we use the height without the value which will work great for all sizes of youtube, but it will change the amazon iframe with height also – most of amazon ads heights are 240px. function add_video_wmode_transparent($html) { if (strpos($html, “<iframe” ) !== false) { $search = array(‘” height=”315″‘, ‘?hd=1?hd=1’); $replace = array(‘?hd=1&wmode=transparent” wmode=”Opaque” height=”315″‘, ‘?hd=1’); $html = str_replace($search, $replace, $html); return $html; } else { return $html; } } 2013-08-14 Retested with ie8 and Safari – didn’t work – need to add “wmode=transparent” – New codes are below and make sure all iframe youtube has “frameborder” right after the “src” and not any other code in between like “allowfullscreen”. function add_video_wmode_transparent($html) { if (strpos($html, “<iframe” ) !== false) { $search = array(‘” frameborder=”0″‘, ‘?hd=1?hd=1’); $replace = array(‘?hd=1&wmode=transparent” frameborder=”0″ wmode=”Opaque”‘, ‘?hd=1’); $html = str_replace($search, $replace, $html); return $html; } else { return $html; } } 2012-10-04 After adding the Share This button to the post, I found out the codes below replace all iframes which Amazon banners ...
  • Add Shortcodes To Sidebar
    Since WordPress is php based, in order to use shortcodes on the sidebar or anywhere on the theme, we have to use echo. <h2><?php echo do_shortcode(‘ catlist categorypage=yes excerpt=yes excerpt_size =255)]’); ?></h2> This is the shortcodes for catlist to list related posts in the same category on the sidebar for my single.php that I’m designing right now (the right bracket before ‘catlist’ is missing).

Leave a Reply

Your email address will not be published. Required fields are marked *