View wp-piklist-metabox-top-pages-only.php
<?php | |
/** | |
* This code went into the file in piklist/parts/metaboxes | |
*/ | |
/* | |
Title: Section Name | |
Post Type: page | |
Top pages only: true | |
*/ |
View wp-add-gallery-title-field.php
<?php | |
/** | |
* Add Title Field | |
* - adds image caption to image tags; will show up as gallery captions | |
* - this example uses image caption if defined, with fallback to post title | |
* - edit as desired to choose post title, description, or caption (excerpt) | |
*/ | |
add_filter( 'wp_get_attachment_link', function( $anchor, $id ) { | |
$_post = get_post( $id ); | |
if ( !$_post ) { |
View wp-post-type-slug-body-class.php
<?php | |
/** | |
* Adds the post type and slug to the <body> class, e.g., "page-about". | |
*/ | |
add_filter( 'body_class', function( $classes ) { | |
global $post; | |
if ( isset( $post ) ) { | |
$classes[]= "{$post->post_type}-{$post->post_name}"; |
View wp-tag-cloud-smaller-fonts.php
<?php | |
/** | |
* Reduce the font sizes in the WordPress tag cloud | |
*/ | |
add_filter( 'widget_tag_cloud_args', function( $args ) { | |
$args['smallest'] = 11; | |
$args['largest'] = 24; | |
$args['unit'] = 'px'; | |
return $args; | |
}); |
View wp-insert-custom-media-sizes.php
<?php | |
/** | |
* Custom Image Sizes | |
* - adds all custom image sizes to the list of choices in Insert Media | |
*/ | |
add_filter( 'image_size_names_choose', function ( $sizes ) { | |
global $_wp_additional_image_sizes; | |
if ( !empty( $_wp_additional_image_sizes ) ) { | |
foreach ( $_wp_additional_image_sizes as $id => $data ) { | |
if ( !isset( $sizes[$id] ) ) |
View wp-widget-shortcode.php
<?php | |
/** | |
* Widget Shortcode | |
* - allows you to insert a widget into any content area using a shortcode | |
* - credit: http://wp.smashingmagazine.com/2012/12/11/inserting-widgets-with-shortcodes/ | |
* - read the comments on the Smashing Magazine article for pros and cons of this function | |
*/ | |
add_shortcode( 'mcw_widget', function ( $atts ) { | |
// configure defaults and extract the attributes into variables | |
extract( shortcode_atts( |
View wp-allow-view-post-editing.php
if ( is_admin() ) { | |
// soften post lock to post warning | |
add_filter( 'show_post_locked_dialog', '__return_false' ); | |
add_filter( 'wp_check_post_lock_window', '__return_false' ); | |
} |
View wp-woocommerce-utility-urls.php
<!-- Get and display the My Account page url --> | |
<?php echo get_permalink( wc_get_page_id( 'checkout' ) ); ?> | |
<!-- Get and display the Cart page url --> | |
<?php echo get_permalink( wc_get_page_id( 'cart' ) ); ?> | |
<!-- Get and display the Shop page url --> | |
<?php echo get_permalink( wc_get_page_id( 'shop' ) ); ?> | |
<!-- Get and display the Checkout page url --> |
View icon-from-svg-code.sccs
/* ========================================================================== | |
SVG to CSS Example: Breadcrumbs "Home Icon" | |
- an example of using the Open Iconic SVG code to create a "home" icon | |
- this is the same method as used in the Bootstrap 4 _variables.sccs file | |
- started by downloading the distro from https://useiconic.com/open | |
- found the 'home' icon SVG and copied its path code | |
- then pasted the path code into one of the Bootstrap icon definitions & | |
changed the fill color | |
========================================================================== */ | |
$link-color: blue; |
OlderNewer