Select Page

Target certain pages using WordPress

Use this code to stop the title of the page such as ‘Home’ from being displayed as the H1 on the homepage.

<?php if (!is_page('Home')) { ?>
      <h1><?php the_title(); ?></h1>
<?php } ?>

WordPress if page exists code

Use this to target code if a certain page exists, useful to show gallery images in a sidebar if there is a gallery page.

if(get_page_by_title('Gallery')) :
{code here}

Add Google Map to WordPress Site

Add the following to the functions.php file

function fn_googleMaps($atts, $content = null) {

"width" => '640',
"height" => '480',
"src" => ''
), $atts));
return '';

add_shortcode("googlemap", "fn_googleMaps");

Here is the shortcode that you need

[googlemap width="200" height="200" src="[url]"]

Get the url from the top right area of

Add breadcrumbs to WordPress without a plugin

Add this to your functions.php file

function the_breadcrumb() {
                echo '<ul id="crumbs">';
        if (!is_home()) {
                echo '<li><a href="';
                echo get_option('home');
                echo '">';
                echo 'Home';
                echo "</a></li>";
                if (is_category() || is_single()) {
                        echo '<li>';
                        the_category(' </li><li> ');
                        if (is_single()) {
                                echo "</li><li>";
                                echo '</li>';
                } elseif (is_page()) {
                        echo '<li>';
                        echo the_title();
                        echo '</li>';
        elseif (is_tag()) {single_tag_title();}
        elseif (is_day()) {echo"<li>Archive for "; the_time('F jS, Y'); echo'</li>';}
        elseif (is_month()) {echo"<li>Archive for "; the_time('F, Y'); echo'</li>';}
        elseif (is_year()) {echo"<li>Archive for "; the_time('Y'); echo'</li>';}
        elseif (is_author()) {echo"<li>Author Archive"; echo'</li>';}
        elseif (isset($_GET['paged']) &amp;&amp; !empty($_GET['paged'])) {echo "<li>Blog Archives"; echo'</li>';}
        elseif (is_search()) {echo"<li>Search Results"; echo'</li>';}
        echo '</ul>';

add this to your index.php, page.php or single.php


Move WordPress site to another domain name

Use these SQL commands if you are moving your website from one domain to another.

Change Siteurl and Homeurl

UPDATE wp_options SET option_value = replace(option_value, '', '') WHERE option_name = 'home' OR option_name = 'siteurl';

Change GUID

UPDATE wp_posts SET guid = REPLACE (guid, '', '');

Change URL in Content

UPDATE wp_posts SET post_content = REPLACE (post_content, '', '');

Change URL in LayerSlider Plugin

UPDATE wp_layerslider SET data = REPLACE (data, '\\\/', 'www.')

WordPress Display last post and image from specific category

Used to display the last post and image from a specific category, this can be useful for latest news on a homepage or latest posts in a sidebar.

query_posts('cat=3&#038;showposts=1'); // replace 123 by category ID of "Headline"  
if(have_posts()) : the_post(); $images = get_children(array( 'post_parent' =  --> get_the_id(),
'post_type' =&gt; 'attachment',
'post_mime_type' =&gt; 'image',
'orderby' =&gt; 'ID',
'order' =&gt; 'ASC',
'numberposts' =&gt; 1
foreach((array)$images as $key =&gt; $image){
echo wp_get_attachment_image($key);

Re-direct all domains to one domain, regardless of subdomain

.htaccess rule to re-direct all domains to one domain, regardless of subdomain

Options +FollowSymlinks

RewriteEngine on
rewritecond %{http_host} !^(.*) [nc]
rewriterule ^(.*)$$1 [r=301,nc]