Skip to content

Instantly share code, notes, and snippets.

View Hexodus's full-sized avatar

Adrian Maleska Hexodus

  • Wiesbaden - Germany
View GitHub Profile
@Hexodus
Hexodus / add_custom_image_sizes_2wordpress.php
Last active August 2, 2017 09:36
Add custom images sizes to Wordpress and Admin area. Found solution here: https://havecamerawilltravel.com/photographer/wordpress-resize-thumbnails Place this code in your functions.php (i.e. in your child theme's folder)
<?php
add_image_size( 'homepage-thumb', 270, 175, false ); //soft crop = resize
add_image_size( 'search-thumb', 150, 150, true ); //hard crop
add_filter( 'image_size_names_choose', 'my_custom_sizes' );
function my_custom_sizes( $sizes ) {
return array_merge( $sizes, array(
'homepage-thumb' => __( 'Homepage Thumb' ),
'search-thumb' => __( 'Search Thumb' ),
) );
@Hexodus
Hexodus / reactivate_admin_toolbar.php
Last active August 2, 2017 09:36
Reactivate Wordpress admin toolbar when it was hidden by the parent theme (idiots are everywhere!). In this case I reactivate it only for admins. Place this code in your functions.php (i.e. in your child theme's folder)
<?php
if( current_user_can('administrator'))
add_filter( 'show_admin_bar', '__return_true' , 1000 );
?>
@Hexodus
Hexodus / wordpress_change_image_compression.php
Last active August 2, 2017 10:14
Change Wordpress default image compression percentage. I'm most happy with 90% ;) Keep in mind that it applies only to new uploaded images - old ones have to be regenerated.
<?PHP
add_filter('jpeg_quality', function($arg){return 90;});
?>
@Hexodus
Hexodus / get_site_thumbnail_instead_of_post.php
Created August 2, 2017 14:48
Wordpress. Method to get the site features image instead of the loop ones. Useful for blogs where usually the_post_thumbnail() would call the first loop image thumbnail.
<?php
$img = wp_get_attachment_image_src(get_post_thumbnail_id(get_option('page_for_posts')),'full');
$featured_image = $img[0];
?>
@Hexodus
Hexodus / wp_custom_excrept_length.php
Created August 2, 2017 16:51
Wordpress set custom excrept length in words.
<?php
//custom excrept length in words
add_filter( 'excerpt_length', function(){ return 40; }, 999 );
?>
yarn create nuxt-app <my-project>