Wednesday, September 18, 2013

Redirect 404 error page to Home on WordPress

Add below 2 lines on 404.php file 

<?php
 header("Status: 301 Moved Permanently");
 header("Location: /");

?>

Media Queries Tutorial - Responsive Website

<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
This will take control of the layout on mobile browsers. Place this inside the tag and you’re ready to go.

-------------------------------------------------------------------------------------------------------------------------------

Working < 960 Viewport

This is our first media query that will target screens less than 960px.
/* VIEWPORT < 960px */
@media only screen and (max-width: 960px){
#container{ width: 768px; }
}
Since our layout is now less than 960px, we will style all the main container elements by changing the width to 768px.

-------------------------------------------------------------------------------------------------------------------------------

Working < 768 Viewport

The above CSS is our second media query that will target screens less than 768px (Tablet Portrait).
/* VIEWPORT < 768px */
@media only screen and (max-width: 768px){
#container{ width: 524px; }
}

-------------------------------------------------------------------------------------------------------------------------------

Working < 524 Viewport

This is our third media query that will target screens less than 524px (Mobile).
@media only screen and (max-width: 524px){
#container{ width: 300px; }
}

-------------------------------------------------------------------------------------------------------------------------------

That's it...

For more detailed info: http://www.1stwebdesigner.com/css/media-queries-tutorial-convert-burnstudio-responsive-website/

Friday, August 2, 2013

HTML file Opening on New Window Script

<a href="#" onClick="myRef = window.open('http://www.orthosports.info/multimedia/X-Ray/X-Ray.html','mywin',
'left=20,top=20,width=732,height=453,toolbar=0,resizable=0,scrollbars=0,toolbar=0,location=0,directories=0,menubar=0,status=0'); myRef.focus()">Click Me</a>

Thursday, April 18, 2013

Go to to page jQuery Script.

****Script ****
  <script type="text/javascript">
    $(function() {
        $.fn.scrollToTop = function() {
            $(this).hide().removeAttr("href");
            if ($(window).scrollTop() != "0") {
                $(this).fadeIn("slow")
            }
            var scrollDiv = $(this);
            $(window).scroll(function() {
                if ($(window).scrollTop() == "0") {
                    $(scrollDiv).fadeOut("slow")
                } else {
                    $(scrollDiv).fadeIn("slow")
                }
            });
            $(this).click(function() {
                $("html, body").animate({
                    scrollTop: 0
                }, "slow")
            })
        }
    });
    $(function() {
        $("#gototop").scrollToTop();
    });
</script>




**** HTML Code ****
<div class="gototop"><a id="gototop" style="display:none;"><img alt="" src="<?php bloginfo(template_url); ?>/images/topicon.png"></a></div>

****CSS***
#gototop{ position:fixed; bottom:40px; right:75px; cursor:pointer; }

Only show div on homepage/blog index in wordpress/php

The following example can be used in your sidebar to display different content when displaying home page. 

<?phpif ( is_home() ) {
    
// This is a homepage} else {
    
// This is not a homepage}?>


 ------------------------
Also here is an other code.

<?php if(is_home()): ?>

<div>Your div.</div>

<?php endif; ?>
Using above code works fine as long as you are not setting static Page for the Front Page display from here Administration > Settings > Reading.
<?php if(is_front_page()): ?>

<div>Your div.</div>

<?php endif; ?>
But this code will work irrespective of whether the main blog page is showing or you have set a static page to show on home page.

How can i put WordPress Shortcode?

Here is the code for shortcode <?php echo do_shortcode("[contentblock id=1]"); ?>

Wednesday, April 17, 2013

Select the last word in an element & wrap it with a span tag

jQuery(document).ready(function($){
    $('.site-name a').html(function(){   
        // separate the text by spaces
        var text= $(this).text().split(' ');
        // drop the last word and store it in a variable
        var last = text.pop();
        // join the text back and if it has more than 1 word add the span tag
        // to the last word
        return text.join(" ") + (text.length > 0 ? ' <span class="last">'+last+'</span>' : last);
    });
});