Posted on Leave a comment

How to Embed Code Snippets in a WordPress Post, and Make It AMP and SEO Friendly

The Problem

WordPress’s Gutenberg editor has a native Code block. It looks like this:

function storefront_post_nav()
{
    $args = [
        'next_text'    => '<span class="screen-reader-text">' . esc_html__('Next post:', 'storefront') . ' </span>%title',
        'prev_text'    => '<span class="screen-reader-text">' . esc_html__('Previous post:', 'storefront') . ' </span>%title',
        'in_same_term' => true,
    ];

    the_post_navigation($args);
}

I’m usually a big fan of native solutions, but this one is just not good enough. It doesn’t have, for example, semantic highlighting, which makes it harder to read. You can do better.

Continue reading How to Embed Code Snippets in a WordPress Post, and Make It AMP and SEO Friendly
Posted on Leave a comment

How to Exclude Your Activity From Your Site’s Code and Analytics

Black and white dog with disguise eyeglasses

The Problem

Sometimes, when working on a WordPress site, you want to exclude your own activity, either from executing code or from analytics tools connected to your site (such as Google Analytics), or both. There are a few possible methods.

Continue reading How to Exclude Your Activity From Your Site’s Code and Analytics