Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Douglas Rosa douglasanro

🏠
Working from home
  • Florianopolis, Brazil
View GitHub Profile
@douglasanro
douglasanro / dashboard-activity-all-cpt.php
Created Apr 22, 2017
Add the support for your WordPress CPT in the widget activity of the admin dashboard
View dashboard-activity-all-cpt.php
<?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 Apr 16, 2017
Create WordPress settings page For custom options
View functions.php
<?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 Apr 16, 2017
Change WordPress more excerpt
View change-more-excerpt.php
<?php
/* ----------------------------------------------------------------------------
* Change more excerpt
* ------------------------------------------------------------------------- */
function custom_more_excerpt( $more ) {
return '...';
}
add_filter( 'excerpt_more', 'custom_more_excerpt' );
@douglasanro
douglasanro / modify-excerpt-length.php
Created Apr 16, 2017
Modify WordPress excerpt length
View modify-excerpt-length.php
<?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 Apr 16, 2017
Modify WordPress admin footer text
View modify-admin-footer-text.php
@douglasanro
douglasanro / switch-default-core-markup-to-output-valid-html5.php
Created Apr 16, 2017
Switch default WordPress core markup to output valid HTML5
View switch-default-core-markup-to-output-valid-html5.php
<?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 Apr 16, 2017
Let WordPress manage the document title
View let-wordpress-manage-the-document-title.php
<?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 Apr 16, 2017
Remove WordPress welcome panel in dashboard
View remove-welcome-panel-in-dashboard.php
<?php
/* ----------------------------------------------------------------------------
* Remove welcome panel in dashboard
* ------------------------------------------------------------------------- */
remove_action('welcome_panel', 'wp_welcome_panel');
@douglasanro
douglasanro / remove-all-dashboard-widgets.php
Created Apr 16, 2017
Remove all WordPress dashboard widgets
View remove-all-dashboard-widgets.php
<?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 Apr 16, 2017
Add WordPress CPT to category and tag archives
View add-cpt-to-category-and-tag-archives.php
<?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;