Tag: PHP
-
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
-
How to fix “Headers already sent” error in PHP
—
in Web designUsato per le pagine deck di mwindaacademy.com Turning on output buffering should make the problem go away; all output after the call to ob_start is buffered in memory until you release the buffer, e.g. with ob_end_flush.
-
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.
-
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)