Remove the shortcode from get_the_content

 

step1: Remove the shortcode from get_the_content():

<?php
  //Remove the shortcode from content
  $content = strip_shortcodes(get_the_content());
?>

 

step2: Remove shortcode on home page but not on single or archive pages(function.php):

<?php
  /*
  * Remove shortcodes on the home page
  *
  */
  function remove_shortcode_from_home( $content ) {
     if ( is_home() ) {
         $content = strip_shortcodes( $content );
     }
     return $content;
  }
   add_filter( 'the_content','remove_shortcode_from_home' );
?>

Google Map

Google Map Options :

var map = new google.maps.Map(document.getElementById('map'), {
    zoom: 2,//Map Zoom view
    disableDoubleClickZoom: true,// Double Click Option
    scrollwheel: false,   // Scroll Zoom
    draggable: false,  // Control Map Position
    center: {lat: 20.24349, lng: 10.08590},
        mapTypeControlOptions: {
     		mapTypeIds: [google.maps.MapTypeId.ROADMAP, customMapTypeId]
	    }
  });

Search Results Filter

Search Filter :

Step 1: WordPress Search Result Fillter function

Put this code in function.php

<?php 
//Hook to Search result
function SearchFilter($query) {
    if ($query->is_search) {
        $query->set('post_type', 'post');
    }
    return $query;
}
add_filter('pre_get_posts','SearchFilter'); 
?>

This function is only filer the posts in search results.

Step 2: WordPress Search Result Fillter With Pages functions

<?php 
//Hook to Search result
function SearchFilter($query) {
    if ($query->is_search) {
        $query->set('post_type', 'post', 'page');
    }
    return $query;
}
add_filter('pre_get_posts','SearchFilter'); 
?>

This function is filer the posts and pages in search results.

Dynamically Change the Image in On load

Dynamically Change the Image in On load

<script type="text/javascript">
var images = [], 
index = 0;
images[0] = "<a href = 'http://www.pfeifferstudio-com.mybigcommerce.com/'><img src='http://cdn6.bigcommerce.com/s-vqetyz9/template/images/Pfeifer-Studio-Logo_beige_1.gif' border='0' id='LogoImage' alt='pfeiferstudio.com'></a>";
images[1] = "<a href = 'http://www.pfeifferstudio-com.mybigcommerce.com/'><img src='http://cdn6.bigcommerce.com/s-vqetyz9/template/images/Pfeifer-Studio-Logo_blue.gif' border='0' id='LogoImage' alt='pfeiferstudio.com'></a>";
images[2] = "<a href = 'http://www.pfeifferstudio-com.mybigcommerce.com/'><img src='http://cdn6.bigcommerce.com/s-vqetyz9/template/images/Pfeifer-Studio-Logo_orange.gif' border='0' id='LogoImage' alt='pfeiferstudio.com'></a>";
images[3] = "<a href = 'http://www.pfeifferstudio-com.mybigcommerce.com/'><img src='http://cdn6.bigcommerce.com/s-vqetyz9/template/images/Pfeifer-Studio-Logo_red.gif' border='0' id='LogoImage' alt='pfeiferstudio.com'></a>";
images[4] = "<a href = 'http://www.pfeifferstudio-com.mybigcommerce.com/'><img src='http://cdn6.bigcommerce.com/s-vqetyz9/template/images/Pfeifer-Studio-Logo_yellow.gif' border='0' id='LogoImage' alt='pfeiferstudio.com'></a>";
index = Math.floor(Math.random() * images.length);
document.write(images[index]);
</script>

Disable the Admin Bar

Step 1: Disable Admin Bar for All Users Except for Administrators

Add below code in function.php :

<?php add_action('after_setup_theme', 'remove_admin_bar');
 
function remove_admin_bar() {
if (!current_user_can('administrator') && !is_admin()) {
  show_admin_bar(false);
}
} ?>

 

Step 2: Disable Admin Bar for All Users

<?php show_admin_bar(false); ?>

Add CSS into wordrpess admin

Add below code into function.php within the active theme folder.

<?php
add_action('admin_head', 'your_custom_func');
function your_custom_func() {
echo '<style>
/* Add your custom style here */
</style>';
}
?>

Above code will add the style into admin header.
admin_head — Admin header hook. Its hooked by add_action.

WooCommerce products per page and List all products

Add below code in function,php to list only particular count product in product list page. Below code will list 12 products per page.

add_filter( 'loop_shop_per_page', create_function( '$cols', 'return 12;' ) );

Use below code to list “All products” in one page.  So, URL should have “URL?showall=1

if( isset( $_GET['showall'] ) ){
add_filter( 'loop_shop_per_page', create_function( '$cols', 'return -1;' ) );
} else {
add_filter( 'loop_shop_per_page', create_function( '$cols', 'return 12;' ) );
}