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).

  • Fix Error 403 – Forbidden WordPress
    I used .htaccess to block out all ip addresses that want to login to Wordpress. Today, I was blocked from my home, although the ip address is the same. Finally by reading the Inmotion hosting website, the ip address it uses for my ip address is different from my isp provider. So, I need to add the ip address from my website host provider and everything works.            
  • How To Implement EU Cookies Warning
    Due to these EU cookies laws, all the website must display a cookie warning for reader to continue or leave.  After so much time to search for the best solution since we display Ad-sense and Amazon ads, we need to comply and finally we found a that shows us how to do it. It’s quite simple. While we’re searching, we found a way to display the text box with a close button to turn it off. We need the scripts $jC(document).ready(function(c) { $jC('.alert-close').on('click', function(c){ $jC(this).parent().fadeOut('slow', function(c){ }); }); }); no-conflict and set in the footer.php <script type="text/javascript"> var $jC=jQuery.noConflict(); $jC(document).ready(function(){ }); </script> <script src="<?php bloginfo('template_url'); ?>/ijs/cookie.js" type="text/javascript"></script> The textbox with close button <div id="cookie"> <p style="text-align=center";><em> Dognmonkey uses <a href="//www.dognmonkey.com/techs/privacy-policy" target="_blank">cookies</a> to give you the best experience. Please continue if you're OK with this.<div class="alert-close">×</div></em></p></div> CSS for the text box #cookie {position:fixed;font-size:.6em; background:url(../images/info_icon.png) 10px 11px #0079a9;background:url(../images/info_icon.png) 10px 11px,-webkit-gradient(linear,50% 0,50% 100%,color-stop(0,#009ddc),color-stop(100%,#0079a9));background:url(../images/info_icon.png) 10px 11px,-moz-linear-gradient(top,#009ddc,#0079a9);background:url(../images/info_icon.png) 10px 11px,-ms-linear-gradient(top,#009ddc,#0079a9);background:url(../images/info_icon.png) 10px 11px,-o-linear-gradient(top,#009ddc,#0079a9);background:url(../images/info_icon.png) 10px 11px,linear-gradient(top,#009ddc,#0079a9);background-repeat:no-repeat;width:100%;color:#fff;height:auto;text-align:center;padding: 2px;word-wrap:break-word;border: 2px solid #fff;bottom:80px;z-index:1000 } .alert-close{background:rgba(255,255,255,.1);-webkit-border-radius:50%;-moz-border-radius:50%;-ms-border-radius:50%;-o-border-radius:50%;border-radius:50%;-webkit-box-shadow:inset 0 1px 2px rgba(0,0,0,.4),inset 0 -1px 2px rgba(255,255,255,.25);-moz-box-shadow:inset 0 1px 2px rgba(0,0,0,.4),inset 0 -1px 2px rgba(255,255,255,.25);box-shadow:inset 0 1px 2px rgba(0,0,0,.4),inset 0 -1px 2px rgba(255,255,255,.25);color:#FFF;cursor:pointer;font-size:24px;font-weight:600;height:24px;line-height:20px;position:absolute;right:11px;top:9px;-webkit-transition:color .2s ease-in-out;-moz-transition:color .2s ease-in-out;-o-transition:color .2s ease-in-out;transition:color .2s ease-in-out;width:24px}
  • Create Shortcodes for Color Buttons With Links
    Bootstrap buttons are great, but for some reasons they don’t accept links. This is how I create color buttons with link using shortcodes. Create the color button in css. bblack,bblue,bgreen,bred, a {text-style:italic;font-size:17px;font-weight:500;color:#fff}bblack span,bblue span,bgreen span,bred span{padding:5px 13px;border-radius:5px}bblack span{background-color:#080808}bblue span{background-color:#1A447A}bred span{background-color:#930700}bgreen span{background-color:#004928} Shortcodes by create btn_shortcodes.php. <?php add_shortcode( ‘blue’, ‘title_s’ ); function title_s($atts, $content = null) { extract(shortcode_atts(array( ‘blue’ => ”, ), $atts)); return ‘<bblue><span>’.$content.'</span></bblue>’ ; } add_shortcode( ‘red’, ‘title_r’ ); function title_r($atts, $content = null) { extract(shortcode_atts(array( ‘red’ => ”, ), $atts)); return ‘<bred><span>’.$content.'</span></bred>’ ; } add_shortcode( ‘green’, ‘title_g’ ); function title_g($atts, $content = null) { extract(shortcode_atts(array( ‘green’ => ”, ), $atts)); return ‘<bgreen><span>’.$content.'</span></bgreen>’ ; } add_shortcode( ‘black’, ‘title_b’ ); function title_b($atts, $content = null) { extract(shortcode_atts(array( ‘black’ => ”, ), $atts)); return ‘<bblack><span>’.$content.'</span></bblack>’ ; } Add btn_shortcodes.php to function.php, make sure the path is correct. include ‘iphp/btn_shortcodes.php’;
  • Set Localhost Port for XAMPP
    Sometimes the network doesn’t allow port 80, when we set up xampp and we can’t access localhost. We need to change the listen port to a new value, and every time we want to access localhost, we need the “:newport”.
  • How To Put Multiple Passwords On A Post In WordPress
    I have some posts that are private and I would like a few people to read only, after some read, I would like to remove their access and still let others to read. After searching on the web, this way is the best way to do it for what I want and it works. 1. Download and install Solepixel/wp-multiple-password plugin. 2. Go to Dashboard->Plugins->Add new->Advanced Custom Fields and install.       Set the password on the post and scroll down to add more passwords: all these passwords will work on the page.      

Leave a Reply

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