Category: Wordpress
-
Lazy Loading in WordPress: Lazy Load Images, Videos, and More
—
Lazy loading defers offscreen images, videos, and iframes until needed, reducing unnecessary requests. This eases pressure on bandwidth and processing, helping the browser manage the main thread and critical rendering path more efficiently. When implemented properly, it improves First Contentful Paint and often Largest Contentful Paint by prioritizing above-the-fold content.
-
Change The WordPress Post Template Via URL Parameter
—
in WordpressUsed in Notes for the iframe on the front page. How To Serve Up A Different Template First we need to let WordPress know about the URL parameter so we can detect it later. We do this by adding the following code to your theme’s functions.php file: Next, we check for the existence of the…
-
register_taxonomy
—
in WordpressIn order to have a taxonomy appear in the URL hierarchy of the relevant CPT, you can rewrite the taxonomy slug to contain the CPT’s slug. But you must register the CPT after registering the taxonomy, otherwise the rewrite will not work, i.e. in this case, book CPT must be registered after genre taxonomy.
-
Prevent stylesheet from being cached
—
in WordpressTo prevent a stylesheet from caching in WordPress using PHP, you can add a query string to the stylesheet URL in your theme’s functions.php file. For example, use wp_enqueue_style( ‘your-style-handle’, get_stylesheet_uri(), array(), time() ); to append the current timestamp, ensuring the browser fetches the latest version on each page load
-
Pagination
—
in WordpressLoop for paginated posts 1) oppure 2)https://wordpress.stackexchange.com/questions/120407/how-to-fix-pagination-for-custom-loops If your page is a static front page, be sure to use ‘page’ instead of ‘paged’ as a static front page uses page and not paged. This is what you should have for a static front page: Esempio (remember $front_query->max_num_pages)
-
Display the post date or “Today” in an archive
—
in WordpressDisplay the post date. Only output the date if the current post’s date is different from the previous one output (like the_date). Use the_date for yesterday or older.Use “Today” for today, but only for the first post of the day (same behaviour as the_date).
-
How to use PHP templates in block themes
—
in WordpressIf WordPress can not find a matching .html file, it tries to find a .php version of that file. I will give you an example of a PHP template for a block theme that uses the header and footer template parts and also displays the blocks from the page content.
-
Smush – Optimize Images | Compress and Lazy Load Images | Convert WebP
—
WordPress plugin, preso da https://wordpress.org/plugins/search/lazy+load/
-
Rules for taxonomy names and post type names
—
in WordpressCustom taxonomy names (and custom post type names) need to comply to a very specific set of rules, otherwise you will encounter pitfalls that there are no work around for. Here is a guide line when choosing names for custom taxonomies (and custom post types)