This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Windows | |
----------- | |
Step 1 - Open following location in your file browser | |
Step 2 - Open 'hosts' file (As administrator) | |
Step 3 - Add this line in bootom of the file | |
Step 4 - If you want that YOUR DOMAIN points your local directory than, add | |
127.0.0.1 YOUR-WEBSITE.COM # Replace 'YOUR-WEBSITE.COM' with your actual domain name | |
# Above '127.0.0.1' is your local IP (Localhost) address | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function wp_maintenance_mode() | |
{ | |
if (!current_user_can('edit_themes') || !is_user_logged_in()) { | |
wp_die('<h1>Under Maintenance</h1><br />Website under planned maintenance. Please check back later.'); | |
} | |
} | |
add_action('get_header', 'wp_maintenance_mode'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// function.php | |
// Disable support for comments and trackbacks in post types | |
function as_remove_comments_support_for_all_cpt() { | |
$post_types = get_post_types(); | |
foreach ($post_types as $post_type) { | |
if(post_type_supports($post_type, 'comments')) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Add a new field in REST API's on an existing WordPress object type. | |
// ref - https://developer.wordpress.org/reference/functions/register_rest_field/ | |
add_action( 'rest_api_init', 'create_api_posts_meta_field' ); | |
function create_api_posts_meta_field() { | |
register_rest_field( | |
'POST_TYPE', // Post type {string/array} | |
'post-meta', // Field name {string} | |
array( // Callback {array} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Register Sidebar | |
*/ | |
function register_google_map_sidebar() { | |
/* Register first sidebar name Primary Sidebar */ | |
register_sidebar( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery(document).ready( | |
function($) { | |
$( '.widget-control-save' ).click( | |
function() { | |
// grab the ID of the save button | |
var saveID = $( this ).attr( 'id' ); | |
// grab the 'global' ID | |
var ID = saveID.replace( /-savewidget/, '' ); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Multi locations marker for Bing Map | |
// Add js file in header along with bing map API key | |
// Ex - http://www.bing.com/api/maps/mapcontrol?key=XXXXXXXXXX' | |
// Ref -https://bingmapsv8samples.azurewebsites.net/#Infobox_MultiplePushpins | |
$all_venue_locations = array( | |
array( | |
'name' => 'India Gate', | |
'address' => 'Address Details, <br> India Gate', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Return post's excerpt without removing HTML tags | |
* | |
* @param int $count total content length to be return | |
* | |
* @return string | |
*/ | |
function Get_As_excerpt($count = 150) | |
{ | |
if (has_excerpt()) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// get current template name (php file) | |
// global $template; | |
// echo basename($template); | |
add_filter('show_admin_bar', '__return_false'); // Hide admin bar from frontend | |
function show_file_path(){ | |
if( isset($_REQUEST['dev']) && (1 == $_REQUEST['dev']) ): | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// WPML Plugin - Get the ID of original Post | |
global $sitepress; // Assuming the plugin is active | |
$original_post_id = apply_filters( | |
'wpml_object_id', | |
get_the_id(), | |
get_post_type(get_the_id()), | |
false, | |
$sitepress->get_default_language() | |
); |