
Copy-paste snippets for blocks, block themes, security, performance, Tailwind CSS, PHP and React. New snippets every Monday, Wednesday and Friday, each one run in a real WordPress before it is published.

Change the order of the WordPress blog and archive loop, for example oldest posts first, with pre_get_posts and without touching templates.

This one is work in progress

Show WordPress previous and next post links with the title and featured image under a single post, with escaped output and no errors on the first post.

Hide the Flickity slider page dots in WordPress when there is only one slide, with one CSS rule that works with Flickity v2 and v3.

Oxygen adding class to images by default “.ct-image”. To target all the images use img tag or .ct-image. If you want to play with more options there are some couple of more settings:

Stop WordPress compressing resized images at quality 82: set your own JPEG and WebP quality with the wp_editor_set_quality filter.

Limit WordPress search results to the post types you choose, such as posts and pages, without touching admin, REST or custom queries.

Stretch an image from inside its WordPress content column to the left or right edge of the page, with a small CSS and JavaScript snippet.

Run JavaScript on page load and window resize in WordPress without jQuery: measure an element and hand its size to CSS as a variable.

Product cat is category name for WooCommerce products category. Thanks, Hammad Wali for sharing this useful code!

Print a WordPress excerpt without HTML tags, shortcodes or a read-more link, cut to a word limit, for cards and templates.

Print just the WordPress category, tag, taxonomy, post type or author archive name in your archive template, without the Category: prefix.

I was banging my head for 2 hours until I got help from Alexander Buzmakov. Function name: get_fieldFunction argument: ACF_fields_slug

after the file path add array, version and then print An entire block stored in function.php should look like this. You can always add it as @media print but with this you will have much more flexibility and load it where you need it. More about Print CSS: https://www.sitepoint.com/css-printer-friendly-pages/ https://www.smashingmagazine.com/2018/05/print-stylesheets-in-2018/

Change the WordPress excerpt length from 55 words to any number, with an optional length per post type, in one small filter.
![Change the WordPress Excerpt […] to a Read More Link](https://code.dplugins.com/wp-content/uploads/2020/01/post-143-thumbnail-1.jpg)
Replace the […] at the end of WordPress excerpts with an accessible Read more link to the right post, escaped and translatable.

List WordPress related posts from the same category under a single post, without the current post and without a plugin.

In code block when you are using script add to PHP tab: You need to put path from /wp-content/ and not just plugins folder PHP JavaScript Note: Got this trick from a good friend Alexander Buzmakov. Visit his tutorials oxywp.com.
3rd party plugins actions admin admin bar archive block-themes block editor Blocks block styles block theme build buttons core CSS custom post types development filters full site editing gutenberg hook hooks Image javascript load styles media Must Have Oxygen performance php plugins react rest api scripts organizer security SEO single product tailwind theme.json Tips updates WooCommerce wordpress wp-cli wp-cron WP Admin