-
-
Save bewho/7fbd9418ed816f1faf5957a2f44d2720 to your computer and use it in GitHub Desktop.
WordPress Common Custom Codes for Functions.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
<?php | |
//* Add new image sizes | |
add_image_size( 'logo-thumb', 270, 180, TRUE ); | |
//* Change the number of portfolio items to be displayed (props Bill Erickson) | |
add_action( 'pre_get_posts', 'minimum_portfolio_items' ); | |
function minimum_portfolio_items( $query ) { | |
if ( $query->is_main_query() && !is_admin() && is_post_type_archive( 'portfolio' ) ) { | |
$query->set( 'posts_per_page', '6' ); | |
} | |
} | |
//* Remove comment form allowed tags | |
add_filter( 'comment_form_defaults', 'minimum_remove_comment_form_allowed_tags' ); | |
function minimum_remove_comment_form_allowed_tags( $defaults ) { | |
$defaults['comment_notes_after'] = ''; | |
return $defaults; | |
} | |
//custom function to get id by slug | |
function get_id_by_slug($page_slug) { | |
$page = get_page_by_path($page_slug); | |
if ($page) { | |
return $page->ID; | |
} else { | |
return null; | |
} | |
} | |
// WordPress SEO plugin move metaboxes down | |
add_filter( 'wpseo_metabox_prio', 'wpseo_prio'); | |
function wpseo_prio () { | |
return 'low'; | |
} | |
//remove Emoji support and head links | |
remove_action( 'wp_head', 'print_emoji_detection_script', 7 ); | |
remove_action( 'admin_print_scripts', 'print_emoji_detection_script' ); | |
remove_action( 'wp_print_styles', 'print_emoji_styles' ); | |
remove_action( 'admin_print_styles', 'print_emoji_styles' ); | |
// Add span to First Word of the Title of WordPress | |
function add_span_to_first_word( $title = '' ) { | |
if(trim($title) != "") | |
{ | |
$title = explode(" ", $title,2); | |
$titleNew = "<span class=\"fn\">$title[0]</span> $title[1]"; | |
return $titleNew; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment