6th October 2016
Add to functions.php
// REMOVE WP EMOJI
remove_action('wp_head', 'print_emoji_detection_script', 7);
remove_action('wp_print_styles', 'print_emoji_styles');
remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );
remove_action( 'admin_print_styles', 'print_emoji_styles' );
4th October 2016
30th September 2016
Add to functions.php file.
function ld_new_excerpt_more($more) {
global $post;
return '...';
}
add_filter('excerpt_more', 'ld_new_excerpt_more');
Add this to the functions.php file.
add_theme_support( 'post-thumbnails' );
Create a file named searchform.php and place this in the root of the theme folder. This will replace the default WordPress search form.
<form role="search" method="get" class="search-form" action="<?php echo home_url( '/' ); ?>">
<input type="text" placeholder="<?php echo esc_attr_x( 'Search website...', 'placeholder' ) ?>"
value="<?php echo get_search_query() ?>" name="s"
title="<?php echo esc_attr_x( 'Search for:', 'label' ) ?>"/>
</form>
18th August 2016
Display taxonomy term name
Two functions that you can add to the functions.php file to show the taxonomy name with or without a link. Use the call attachedĀ to display this on the page.
17th August 2016
Get the current page ID and use that in the WordPress query to exclude that post from displaying.
<?php $currentID = get_the_ID();?>
<?php $args = array(
'post_type' => 'post',
'post__not_in' => array($currentID)
);
$query = new WP_Query($args);
$i = 1;
while ( $query->have_posts() ) : $query-> the_post(); ?>
1st July 2016
Add this code in to your functions.php to create a domain whitelist for user registrations.
add_action('registration_errors', 'sizeable_restrict_domains', 10, 3);
function sizeable_restrict_domains( $errors, $login, $email ) {
$whitelist = array(
'domain.com',
'website.com'
);
if ( is_email($email) ) {
$parts = explode('@', $email);
$domain = $parts[count($parts)-1];
$to = 'your@adminemail.com';
$subject = 'Subject of email';
$message = 'A user tried to register with the following email address: ' . $email;
if ( !in_array(strtolower($domain), $whitelist) ) {
$errors->add('email_domain', __('ERROR: You may only register with an approved email address.'));
wp_mail( $to, $subject, $message );
}
}
return $errors;
}
28th June 2016
Use to show content if a user is logged in.
<?php if ( is_user_logged_in() ) { ?>
.....Content here......
<?php } ?>
Use ! is_user_logged_in() if you want to show if NOT logged in.
23rd May 2016
Paste this in to your functions.php file – this assumes your CPT is called ‘products’
add_filter( 'posts_search_orderby', function( $search_orderby ) {
global $wpdb;
return "{$wpdb->posts}.post_type LIKE 'products' DESC, {$search_orderby}";
});