Skip to content

Instantly share code, notes, and snippets.

View gdeguglielmo's full-sized avatar

Giuseppina De Guglielmo gdeguglielmo

View GitHub Profile
@gdeguglielmo
gdeguglielmo / remove_empty_p
Created April 24, 2014 13:05
Remove WordPress empty paragraph
function working_remove_empty_p($content) {
$array = array (
'<p>[' => '[',
']</p>' => ']',
']<br />' => ']',
']<br />' => ']'
);
$content = strtr($content, $array);
return $content;
}
@gdeguglielmo
gdeguglielmo / WordPress - Show every result on search page
Created August 26, 2013 14:58
WordPress - Show every result on search page
/* Display all results on search page */
function change_wp_search_size($query) {
if ( $query->is_search ) // Make sure it is a search page
$query->query_vars['posts_per_page'] = -1; // Change 10 to the number of posts you would like to show
return $query; // Return our modified query variables
}
add_filter('pre_get_posts', 'change_wp_search_size');
@gdeguglielmo
gdeguglielmo / Get all the attachments with WP Simple Gallery
Last active December 21, 2015 12:19
Get all the attachments with WP Simple Gallery
@gdeguglielmo
gdeguglielmo / gist:6304549
Created August 22, 2013 08:27
Wordpress attachments functions
// To get thumbnail from image id
wp_get_attachment_image($attachment->ID, 'thumbnail' );
@gdeguglielmo
gdeguglielmo / Check if a number is even or odd
Last active December 21, 2015 11:39
Check if a number is even or odd
// Method 1
$number = 3;
if($number & 1){
echo 'Odd number!';
}else{
echo 'Even number!';
}
// Method 2