This file contains 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_action( 'wp_head', 'cyb_add_search_box_schemas' ); | |
function cyb_add_search_box_schemas() { | |
if ( is_front_page() && (int) get_query_var( 'paged', 0 ) < 1 ) { | |
// Add schemas site markup for Site Name and Site Link search box. | |
// See https://developers.google.com/structured-data/slsb-overview | |
// and https://developers.google.com/structured-data/site-name | |
$searchbox = [ | |
'@context' => esc_js( 'http://schema.org' ), | |
'@type' => 'WebSite', |
This file contains 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 | |
//Add a custom admin dashboard welcome widget | |
function custom_dashboard_widget() { | |
echo '<h1>Welcome to your new WordPress site built by an awesome developer</h1>'; | |
} | |
function add_custom_dashboard_widget() { | |
wp_add_dashboard_widget('custom_dashboard_widget', 'Integrity Welcomes You To WordPress!', 'custom_dashboard_widget'); | |
} | |
add_action('wp_dashboard_setup', 'add_custom_dashboard_widget'); |
This file contains 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
#301 Redirects for .htaccess | |
#Redirect a single page: | |
Redirect 301 /pagename.php http://www.domain.com/pagename.html | |
#Redirect an entire site: | |
Redirect 301 / http://www.domain.com/ | |
#Redirect an entire site to a sub folder | |
Redirect 301 / http://www.domain.com/subfolder/ |
This file contains 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
//Page specific css and/or javascript -- Add to header.php | |
<?php | |
if (is_page_template('page-archives.php')) { ?> | |
<link rel="stylesheet" href="<?php bloginfo('template_url'); ?>/css/ archives.css" type="text/css" media="screen" /> | |
<script type="text/javascript" src="<?php bloginfo('template_url'); ?>/ js/archives.js"></script> | |
<?php } |
This file contains 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
/** Remove jQuery scripts from begining */ | |
add_action('wp_enqueue_scripts', 'wbxp_script_remove_header'); | |
function wbxp_script_remove_header() { | |
wp_deregister_script( 'jquery' ); | |
} | |
/** Load jQuery script at the end */ | |
add_action('genesis_after_footer', 'wbxp_script_add_body'); | |
function wbxp_script_add_body() { | |
wp_register_script( 'jquery', 'https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js', false, null); |
This file contains 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 | |
// This is the cleaner code per request of a thread in the LinkedIn group "WordPress" | |
// ... | |
// register and enqueue loadCSS | |
function load_scripts_and_styles() { | |
// register loadCSS | |
wp_register_script( 'load-css-async', get_stylesheet_directory_uri() . '/path/to/js/loadCSS.js', array(), '', false ); |
This file contains 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
/* | |
Useful WordPress SQL Queries | |
*/ | |
/* | |
Add a Custom Field to All Posts & Pages | |
--- | |
This snippet will add a custom field to every post and page found in your | |
WP database. All you have to do is replace the UniversalCutomField to | |
whatever Custom Field name you like to create, and then change |
This file contains 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
/* Change background */ | |
body.login { | |
background-image: url('home-bg.jpg'); | |
background-repeat: no-repeat; | |
background-attachment: fixed; | |
background-position: center; | |
} | |
/* Change login logo */ | |
.login h1 a { |
This file contains 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 | |
// Flush rewrite rules after switch theme | |
function my_rewrite_flush() { | |
flush_rewrite_rules(); | |
} | |
add_action( 'after_switch_theme', 'my_rewrite_flush' ); | |
// A little help so we can get the stylesheet from parent theme | |
// Remove line 10-19 if this is not a child theme | |
function my_enqueue_styles() { |