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 / let-wordpress-manage-the-document-title.php
Created April 16, 2017 22:17
Let WordPress manage the document title
<?php
/* ----------------------------------------------------------------------------
* Let WordPress manage the document title
* ------------------------------------------------------------------------- */
// Add the following to functions.php and remove the <title> tag from your header.
add_theme_support( 'title-tag' );
@douglasanro
douglasanro / remove-welcome-panel-in-dashboard.php
Created April 16, 2017 22:15
Remove WordPress welcome panel in dashboard
<?php
/* ----------------------------------------------------------------------------
* Remove welcome panel in dashboard
* ------------------------------------------------------------------------- */
remove_action('welcome_panel', 'wp_welcome_panel');
@douglasanro
douglasanro / remove-all-dashboard-widgets.php
Created April 16, 2017 22:14
Remove all WordPress dashboard widgets
<?php
/* ----------------------------------------------------------------------------
* Remove all dashboard widgets
* ------------------------------------------------------------------------- */
function remove_dashboard_widgets() {
global $wp_meta_boxes;
unset( $wp_meta_boxes['dashboard']['side']['core']['dashboard_quick_press'] );
unset( $wp_meta_boxes['dashboard']['normal']['core']['dashboard_incoming_links'] );
unset( $wp_meta_boxes['dashboard']['normal']['core']['dashboard_right_now'] );
@douglasanro
douglasanro / add-cpt-to-category-and-tag-archives.php
Created April 16, 2017 22:13
Add WordPress CPT to category and tag archives
<?php
/* ----------------------------------------------------------------------------
* Add CPT to category and tag archives
* ------------------------------------------------------------------------- */
function simple_add_custom_types( $query ) {
if( is_category() || is_tag() && empty( $query->query_vars['suppress_filters'] ) ) {
$post_types = get_post_types();
$query->set( 'post_type', $post_type );
return $query;
@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' );