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 / dashboard-activity-all-cpt.php
Created April 22, 2017 03:31
Add the support for your WordPress CPT in the widget activity of the admin dashboard
<?php
/* ----------------------------------------------------------------------------
* Add the support for your CPT in the widget activity of the admin dashboard
* ------------------------------------------------------------------------- */
add_filter( 'dashboard_recent_posts_query_args', 'add_page_to_dashboard_activity' );
function add_page_to_dashboard_activity( $query_args ) {
// Return all post types
$query_args['post_type'] = 'any';
// Or return post types of your choice
// query_args['post_type'] = array( 'post', 'foo', 'bar' );
@douglasanro
douglasanro / functions.php
Created April 16, 2017 22:22
Create WordPress settings page For custom options
<?php
// Let’s instantiate this class in our functions.php file:
if( is_admin() ) {
require 'simple_settings_page.php';
new simple_settings_page();
}
@douglasanro
douglasanro / change-more-excerpt.php
Created April 16, 2017 22:19
Change WordPress more excerpt
<?php
/* ----------------------------------------------------------------------------
* Change more excerpt
* ------------------------------------------------------------------------- */
function custom_more_excerpt( $more ) {
return '...';
}
add_filter( 'excerpt_more', 'custom_more_excerpt' );
@douglasanro
douglasanro / modify-excerpt-length.php
Created April 16, 2017 22:19
Modify WordPress excerpt length
<?php
/* ----------------------------------------------------------------------------
* Modify excerpt length
* ------------------------------------------------------------------------- */
function custom_excerpt_length( $length ) {
return 25;
}
add_filter( 'excerpt_length', 'custom_excerpt_length', 999 );
@douglasanro
douglasanro / modify-admin-footer-text.php
Created April 16, 2017 22:18
Modify WordPress admin footer text
@douglasanro
douglasanro / switch-default-core-markup-to-output-valid-html5.php
Created April 16, 2017 22:17
Switch default WordPress core markup to output valid HTML5
<?php
/* ----------------------------------------------------------------------------
* Switch default core markup to output valid HTML5
* ------------------------------------------------------------------------- */
add_theme_support( 'html5', array(
'search-form', 'comment-form', 'comment-list', 'gallery', 'caption',
) );
@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;