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 | |
// Alternative to defining in wp-config.php `define( 'WP_POST_REVISIONS', 3 );` | |
add_filter( 'wp_revisions_to_keep', function() { | |
return 10; | |
} ); |
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 | |
// add filter to allow for new weekly schedule | |
add_filter( 'cron_schedules', 'my_weekly_cron' ); | |
function my_weekly_cron( $schedules ) { | |
// Adds once weekly to the existing schedules. | |
$schedules['weekly'] = array( | |
'interval' => 604800, | |
'display' => __( 'Once Weekly' ) | |
); |
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 an attachment ID given a URL. | |
* | |
* @param string $url | |
* @return mixed int $attachment_id on success || false on failure | |
*/ | |
function prefix_get_attachment_id( $url ) { | |
$attachment_id = false; |
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 prefix_find_first_imamge( $post ) { | |
$content = $post->post_content; | |
$output = preg_match_all( '/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $content, $matches ); | |
$first_img = $matches[1][0]; | |
if( empty( $first_img ) ) { | |
return false; | |
} |
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 prefix_get_first_attachment( $post ) { | |
$attachment = get_children( | |
array( | |
'post_parent' => $post->ID, | |
'post_type' => 'attachment', | |
'post_mime_type' => 'image', | |
'order' => 'DESC', | |
'numberposts' => 1, | |
) |
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 prefix_remove_first_image( $content ) { | |
if ( !is_page() && !is_feed() && !is_home() ){ | |
$content = preg_replace( "/<img[^>]+\>/i", "", $content, 1 ); | |
} | |
return $content; | |
} | |
add_filter( 'the_content', 'prefix_remove_first_image' ); |
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 | |
/** | |
* Using wp_dropdown_categories with the post type filter applied. | |
* | |
* @link https://joshuadnelson.com/category-taxonomy-dropdown-filtered-by-post-type/ | |
*/ | |
// Taxonomy dropdown arguments | |
$args = array( | |
'taxonomy' => 'department', |
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 | |
wp_nav_menu( array( | |
'menu' => 'Menu Name', | |
'sub_menu' => true, | |
'direct_parent' => true | |
) ); |
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 | |
/** | |
* Template Loader | |
* | |
* This file is read by WordPress to generate the plugin information in the plugin | |
* admin area. This file also includes all of the dependencies used by the plugin, | |
* registers the activation and deactivation functions, and defines a function | |
* that starts the plugin. | |
* | |
* @link https://github.com/misfist/template-loader |
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 prefix_remove_jetpack_styles() { | |
wp_deregister_style( 'jetpack-carousel' ); // Carousel | |
wp_deregister_style( 'the-neverending-homepage' ); // Infinite Scroll | |
wp_deregister_style( 'post-by-email' ); // Post by Email | |
wp_deregister_style( 'publicize' ); // Publicize | |
wp_deregister_style( 'sharedaddy' ); // Sharedaddy | |
wp_deregister_style( 'sharing' ); // Sharedaddy Sharing | |
wp_deregister_style( 'stats_reports_css' ); // Stats | |
wp_deregister_style( 'jetpack-widgets' ); // Widgets |