How to build an expiring function in WordPress?

In this code we are getting the Publish Date using get_the_date() to retrieve the publish date of the current post. and then calculating the difference by comparing the publish date with the current date. After this we conditionally output the script. The condition is if the publish date is within the last 30 days, output … Read more

Changing a page title while the page is being built

It seems that the way you attached your function to the document_title_parts filter is wrong. As per WordPress documentation, document_title_parts only accepts one parameters, array $title. So it doesn’t make sense that when you have 2 parameters in your function. I suggest you do something like this: function custom_document_title( $title_parts ) { // Here is … Read more

How to generate programmatically a post which displays a chunk of content from two different posts belonging to two different Custom Post Types?

To display content from two Custom Post Types (CPTs), like “Books” and “Authors,” on a third CPT (e.g., “Quotes”), follow these steps: 1. Create a “Quotes” Post Type In functions.php, register a new CPT: function create_quote_post_type() { register_post_type( ‘quote’, array( ‘labels’ => array( ‘name’ => __( ‘Quotes’ ), ‘singular_name’ => __( ‘Quote’ ) ), ‘public’ … Read more

Is it possible to remove the “Shop” title from the WooCommerce catalogue? [closed]

CSS METHOD To hide with CSS this should do the trick for you. Add the following to the theme’s or child theme’s style.css, or to the Customizer’s CSS section: body.post-type-archive-product .bs-card-box.page-entry-title { display: none; } What we’re doing here is targeting the product archive template file that WooCommerce uses to dynamically create that page. By … Read more

Hide ID for WordPress User Role Subscriber

You can use the body_class filter and the wp_get_current_user() function to add the current user’s role to the <body> element, and then hide your elements with that (untested): add_filter( ‘body_class’, static function ( $classes ) { $user = wp_get_current_user(); $roles = $user->roles; if ( ! is_array( $roles ) ) { $roles = array( ‘subscriber’ ); … Read more

Get Page URl when changing slug and permalink

Instead of hardcoding the slug, instead store the ID in an option and then use it to call get_permalink(). You can also avoid hardcoding the $baseUrl and rely on a nav menu or button block instead so that it automatically updates. For example, $page_id = …..; // maybe a `get_option` call or something else? Depends … Read more