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 / 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 / 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 / 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 / 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 / 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 / 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 / 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',
) );