<?php
the_post_thumbnail( '', array( 'loading' => 'eager' ) );
Tag: WordPress
-
Disable lazyload on WordPress image
-
Make WordPress next / previous blog pagination buttons have left / right alignment
<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; } }
-
Only output HTML for a WordPress menu location, if a menu is set for that location
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' ] ) ?: ''; ?>
-
Enable block editor for WordPress custom post type
<?php $args = [ 'show_in_rest' => true ]; register_post_type( 'post-type-slug', $args );
-
Disallow adding and deleting plugins in WordPress admin via wp-config.php
Suitable for when you are managing WordPress plugin install and updates via composer and you don’t want admin users changing them.
<?php // Add to or edit in wp-config.php. define( 'DISALLOW_FILE_MODS', TRUE ); define( 'DISALLOW_FILE_EDIT', TRUE );