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).
- Working With Z-Index In CSSIn CSS, z-index is the order of appearance of one layer over the other, the higher the z-index the higher priority of the layer above the lower z-index displays. For example, on my theme, I made header to be fixed with z-index:9999 and my shadowbox overlay z-index:999 . So, on a small display like 1024×768, there’s not enough room for both header and the shadowbox overlay, the shadowbox display will be UNDER the header because the z-index is lower. Always test all the overlay modals over any fixed css or youtube.
- John Dyer HTML5 PlayerThese days with many browsers across the boards, HTML5 seems to get along with all of them. Flash player may not work in some devices. I found this John Dyer HTML5 player that can play very well on WordPress. It’s simple to use and it does work well as core, but if you don’t have WordPress and use it on any other platform, this is how I would do it. Download the scripts and put on the footer or header. If you’re using many jquery, it’s a good practice to define jquery.noConflict with the scripts. <script src=”/idogjs/johndyer/build/jquery.js”></script> <script src=”/idogjs/johndyer/build/mediaelement-and-player.min.js”></script> <link rel=”stylesheet” href=”/idogjs/johndyer/build/mediaelementplayer.min.css” /> <script type=”text/javascript”> var $jD=jQuery.noConflict(); $jD(document).ready(function(){ }); </script> <script src=”/idogjs/johndyer/ijohndyer.js” type=”text/javascript”></script> The ijohndyer.js is my special scripts to take care of all the scripts so we don’t have to repeat the scripts on every post or every player we use. $jD(document).ready(function() { $jD(‘audio,video’).mediaelementplayer({ success: function(player, node) { $jD(‘#’ + node.id + ‘-mode’).html(‘mode: ‘ + player.pluginType); } }); }); When everything is done, all we need to do to place an audio player is coded like this. <audio controls=”control” preload=”none” src=”/music/idog/idogsunday.mp3″ type=”audio/mp3″></audio> For mp4 video player the code is like this. <video width=”560″ height=”315″ src=”/media/teststuff/tasting.mp4″ type=”video/mp4″ id=”player1″ poster=”/media/teststuff/tn_cab04_75.JPG” controls=”controls” preload=”none”></video> Since the scripts is taken care in the head or footer already, we never have to worry about it again.
- Optimize Websites For Speed And CPU UsagesAfter setting up blog(s) on server, create themes, write posts, get traffic, then we need to optimize the websites to be fast and efficient. There are 2 webtools to check the speed of our pages. 1. Move all JavaScripts to Footer instead on placing them on the <head> sections. We want to load the whole page up fast before any scripts. 2. Use js minify & css minify tools to minify all css and js files used on the footer to reduce the sizes for faster page loading. 3. Compress and deflate files at the server level for faster page loading. Add commands in .htaccess of the blog. # BEGIN Compress text files <ifModule mod_deflate.c> AddOutputFilterByType DEFLATE text/html text/plain text/xml application/xml application/xhtml+xml text/css text/javascript application/javascript application/x-javascript </ifModule> # END Compress text files 4. To reduce CPU usage – Turn off the WP_Cron in the wp_config.php file and install super cache plugin. 5. Spams also cause CPU usage – to prevent spam to login as administrator – add the ip address and deny all others in .htaccess.
- Add Excerpts To WordPress ThemesThere are 2 WordPress themes that I like to use, Twenty Ten and Twenty Thirteen for WP 3.6. The Excerpts is only applied to search by default. If we want excerpts to all main page, categories, and archives, we have to add some conditions in “content.php” for Twenty Thirteen and “loop.php” for Twenty Ten. Twenty Ten Theme “loop.php” <?php if ( is_archive() || is_search()||is_home()||is_author()||is_tag() ) : // Only display excerpts for archives and search. ?> <div class=”entry-summary”> <?php the_excerpt(); ?> </div><!– .entry-summary –> Twenty Thirteen Theme “content.php” <?php if ( is_search()||is_author()||is_tag()||is_archive()||is_home() ) : // Only display Excerpts for Search ?> <div class=”entry-summary”> <?php the_excerpt(); ?> </div><!– .entry-summary –>
- Limit WP-Login.php With .htaccessTo limit the WP-login.php to specific ip addresses only (owners, editors) we can add these lines on the blog .htaccess (not the root). The order has to be correct, deny first then allow. Every where we want to log in, we have to find out the ip address and add it in the .htaccess to edit or add posts in WordPress. <FilesMatch wp-login.php> order deny,allow deny from all Allow from xx.xx.xx.xxx </FilesMatch>