Skip to content

Instantly share code, notes, and snippets.

View douglasanro's full-sized avatar
🗺️
Working from anywhere

Douglas Rosa douglasanro

🗺️
Working from anywhere
View GitHub Profile
@douglasanro
douglasanro / remove-default-image-sizes.php
Created April 16, 2017 21:02
Remove default WordPress image sizes
<?php
/* ----------------------------------------------------------------------------
* Remove default image sizes
* ------------------------------------------------------------------------- */
function remove_default_image_sizes( $sizes ) {
/* Default WordPress */
unset( $sizes['thumbnail'] ); // Remove Thumbnail (150 x 150 hard cropped)
unset( $sizes['medium'] ); // Remove Medium resolution (300 x 300 max height 300px)
@douglasanro
douglasanro / add-numeric-pagination-to-your-theme.php
Created April 16, 2017 21:01
Add numeric pagination to your WordPress theme
<?php
/* ----------------------------------------------------------------------------
* Add numeric pagination to your theme
* ------------------------------------------------------------------------- */
function numeric_posts_nav() {
if( is_singular() )
return;
@douglasanro
douglasanro / add-breadcrumbs-to-your-theme.php
Last active April 20, 2017 23:48
Add breadcrumbs to your WordPress theme
<?php
/* ----------------------------------------------------------------------------
* Add breadcrumbs to your theme
* ------------------------------------------------------------------------- */
function simple_breadcrumbs() {
/* === OPTIONS === */
$text['home'] = 'Home'; // text for the 'Home' link
$text['category'] = 'Archive by Category "%s"'; // text for a category page
@douglasanro
douglasanro / create-custom-wordpress-dashboard-widget.php
Created April 16, 2017 20:56
Create custom WordPress dashboard widget
<?php
/* ----------------------------------------------------------------------------
* Create custom WordPress dashboard widget
* ------------------------------------------------------------------------- */
function dashboard_widget_function() {
echo '
<h2>Custom Dashboard Widget</h2>
<p>Custom content here</p>
';
@douglasanro
douglasanro / add-cpt-count-action-to-wordpress-dashboard.php
Created April 16, 2017 20:56
Add CPT count action to WordPress dashboard
<?php
/* ----------------------------------------------------------------------------
* Add CPT count action to WordPress dashboard
* ------------------------------------------------------------------------- */
add_action( 'dashboard_glance_items', 'simple_glance_items' );
// Showing all custom posts count
function simple_glance_items() {
$glances = array();
@douglasanro
douglasanro / add-cpt-to-your-main-wp-rss-feed.php
Created April 16, 2017 20:55
Add CPT to your main WP RSS feed
<?php
/* ----------------------------------------------------------------------------
* Add CPT to your main WordPress RSS feed
* ------------------------------------------------------------------------- */
function simple_feed_request( $rss ) {
if ( isset( $rss[ 'feed' ] ) && !isset( $rss['post_type'] ) ) {
// Return all post types
$rss['post_type'] =
// Return posts of post types of your choice like 'post' and 'news'
@douglasanro
douglasanro / remove-comments.php
Created April 16, 2017 20:54
Remove WordPress comments
<?php
/* ----------------------------------------------------------------------------
* Remove comments
* ------------------------------------------------------------------------- */
// Removes from admin menu
add_action( 'admin_menu', 'my_remove_admin_menus' );
function my_remove_admin_menus() {
remove_menu_page( 'edit-comments.php' );
}
@douglasanro
douglasanro / disable-wordpress-emoji.php
Created April 16, 2017 20:53
Disable WordPress emoji
<?php
/* ----------------------------------------------------------------------------
* Disable WordPress emoji
* ------------------------------------------------------------------------- */
function disable_wp_emojicons() {
remove_action( 'admin_print_styles', 'print_emoji_styles' );
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' );
@douglasanro
douglasanro / disable-built-in-post-type.php
Created April 16, 2017 20:52
Disable built-in post type from WordPress
<?php
/* ----------------------------------------------------------------------------
* Disable built-in post type
* ------------------------------------------------------------------------- */
add_action( 'init', 'simple_remove_default_post_type', 1 );
function simple_remove_default_post_type() {
register_post_type( 'post', array(
'map_meta_cap' => false
) );
@douglasanro
douglasanro / remove-wordpress-version-from-header.php
Created April 16, 2017 20:50
Remove WordPress version from header
<?php
/* ----------------------------------------------------------------------------
* Remove WordPress version from header
* ------------------------------------------------------------------------- */
function simple_remove_version_info() {
return '';
}
add_filter( 'the_generator', 'simple_remove_version_info' );