Add to wp-config.php:
define( 'DISALLOW_FILE_MODS', true );
Useful when managing plugin updates via Composer.
Add to wp-config.php:
define( 'DISALLOW_FILE_MODS', true );
Useful when managing plugin updates via Composer.
<div class="blog-navigation"><?php posts_nav_link( ' ', 'Previous', 'Next' ); ?></div>
.blog-navigation {
display: flex;
justify-content: flex-start;
padding: 1rem 0;
a {
@extend .button;
@extend .button--primary;
}
// Ensures Next button is always right aligned, even when no Previous button
a:last-of-type {
margin-left: auto;
}
}
Otherwise it falls back to echoing another menu (the first?) instead of nothing.
<?= wp_nav_menu( [ 'echo' => false, 'fallback_cb' => false, 'theme_location' => 'footer-2-a' ] ) ?: ''; ?>
<?php
$args = [ 'show_in_rest' => true ];
register_post_type( 'post-type-slug', $args );
In this example, I’m modifying all the posts with a legacy custom post type that I want to get rid of to use the Yoast SEO: Local custom post type for locations instead.
wp post update $(wp post list --post_type=locations --format=ids) --post_type=wpseo_locations
You need to set the loading attribute to eager.
wp_get_attachment_image(
$image_id,
'full',
false,
[ 'loading' => 'eager' ], // Prevent image from being lazy loaded.
);
<?php
namespace NickDavis\AsyncExample;
const ASYNC_EXAMPLE = 'nd-async-example';
add_action( 'wp_enqueue_scripts', __NAMESPACE__ . '\enqueue_script' );
/**
* Enqueues the async example script.
*
* @since v1.0.0
*/
function enqueue_script() {
wp_enqueue_script( ASYNC_EXAMPLE, '//async.example.com', [], null, true );
}
add_filter( 'script_loader_tag', __NAMESPACE__ . '\add_async_attribute', 10, 2 );
/**
* Add an aysnc attribute to an enqueued script.
*
* @url https://wordpress.stackexchange.com/a/198372
*
* @since v1.0.0
*
* @param string $tag Tag for the enqueued script.
* @param string $handle The script's registered handle.
* @return string Script tag for the enqueued script
*/
function add_async_attribute( $tag, $handle ) {
// Just return the tag normally if this isn't one we want to async.
if ( ASYNC_EXAMPLE !== $handle ) {
return $tag;
}
return str_replace( ' src', ' async src', $tag );
}
https://github.com/jeremyfelt/valet-plus/commit/7716adaabbe451641d6c90a299e7fc1e02bc7848
https://clorith.net/updating-jquery-code-in-your-unmaintained-wordpress-plugin-or-theme/