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 | |
/** | |
* Get published and modified date with the WordPress function get_post_timestamp() and convert it into a readable format | |
* https://developer.wordpress.org/reference/functions/get_post_timestamp | |
*/ | |
function published_modified_date() { | |
// UNIX published date | |
$unix_published_date = get_post_timestamp( '', 'date' ); |
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 Google Fonts to WordPress | |
* Add this to your functions.php file | |
*/ | |
function add_google_fonts() { | |
wp_enqueue_style( 'textdomain-add-google-fonts', 'https://fonts.googleapis.com/css?family=Prata&display=swap', false ); | |
} | |
add_action( 'wp_enqueue_scripts', 'add_google_fonts' ); |
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 body class if WordPress page template | |
* @link https://developer.wordpress.org/reference/functions/body_class/ | |
*/ | |
add_filter( 'body_class', 'custom_class' ); | |
function custom_class( $classes ) { | |
if ( is_page_template( 'page-example.php' ) ) { | |
$classes[] = 'example'; | |
} |
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 | |
/** | |
* Detect Tribe Events page | |
* @link https://wordpress.stackexchange.com/questions/340515/writing-a-function-to-detect-an-event | |
*/ | |
function is_tribe_calendar() { | |
if (tribe_is_event() || tribe_is_event_category() || tribe_is_in_main_loop() || tribe_is_view() || 'tribe_events' == get_post_type() || is_singular( 'tribe_events' )) { | |
return true; | |
} | |
else { |
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 Google Analytics | |
* Add this to your theme functions.php file | |
* @link https://gist.github.com/samkent/1df2429b6505c272c7a6bf5799844840 | |
*/ | |
add_action('wp_head', 'google_analytics'); | |
function google_analytics() { | |
?> |
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
<!-- Method one --> | |
<h1><?php the_title(); ?></h1> | |
<!-- Method two --> | |
<?php the_title( '<h1>', '</h1>' ); ?> |
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 | |
/** | |
* Remove emojicons | |
* Add the following to your theme functions.php file. | |
* @link http://wordpress.stackexchange.com/questions/185577/disable-emojicons-introduced-with-wp-4-2 | |
*/ | |
function disable_wp_emojicons() { | |
remove_action( 'admin_print_styles', 'print_emoji_styles' ); | |
remove_action( 'wp_head', 'print_emoji_detection_script', 7 ); | |
remove_action( 'admin_print_scripts', 'print_emoji_detection_script' ); |
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 body class for a specific page template | |
* Add the following to your theme functions.php file. | |
*/ | |
add_filter( 'body_class', 'custom_class' ); | |
function custom_class( $classes ) { | |
if ( is_page_template( 'templates/page-contact.php' ) ) { | |
$classes[] = 'contact'; | |
} |
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
/** | |
* Contact Form 7 only enqueue if page | |
* | |
* @author Sam Kent | |
* @link http://www.samkent.com | |
*/ | |
function contact_form_7_cleanup() { | |
// Dequeue scripts and styles | |
wp_dequeue_script( 'contact-form-7' ); | |
wp_dequeue_style( 'contact-form-7' ); |