Find hours between post_date and post_date_gmt

If all you need to do is check the difference, rather than display or modify anything, then you don’t need to do anything complicated with date_diff(). All you need to do is compare the number of seconds returned by get_post_time() for each date. get_post_time() returns the Unix timestamp for the date, which is simply the … Read more

Is it bad to add html to a widget by closing and reopening the php tags?

“Practice” is a matter of personal preference. The opening and closing PHP tags (<?php and ?>) are there as a matter of convenience. Basically, try to write your code in context. In example, // PHP code here ?><a href=”https://wordpress.stackexchange.com/questions/368897/<?php the_permalink() ?>”><?php the_title() ?></a><?php // PHP code here looks (to me) like HTML code plopped right … Read more

Is there a way to hook or call a custom woocomerce template that is not part of the default templates of woocommerce?

You could consider using the good ol’ get_template_part( string $slug, string $name = null, array $args = array() function, which is a native WP function. Especially now as it supports the third parameter for passing data to the template file (since WP 5.5). Create a function (in your (child) theme functions.php file) that wraps around … Read more

Error – ‘create_function is deprecated’ [closed]

You no longer need to use create_function you can instead just use an anonymous function: add_action( ‘gform_preview_footer’, create_function( ”, ‘GFFormDisplay::footer_init_scripts(‘ . $form[‘id’] . ‘);’ ) ); Should be: add_action( ‘gform_preview_footer’, function() use ($form){ GFFormDisplay::footer_init_scripts($form[‘id’]); }); https://www.php.net/manual/en/functions.anonymous.php

Update a buggy installation

You have two tasks to solve here: 1. Resolve the time-out problem. 2. Update WordPress. Resolve the time-out problem These things don’t just happen because your WP is old. There must be a concrete reason. The three most common reasons are: Not enough memory. Maybe your hosting provider has limited the memory? Try adding the … Read more

wp_force_remove_style’ not found

You have an action, but not the valid callback for your action. For example, You have somewhere following line: add_action( ‘some_action’, ‘wp_force_remove_style’ ); But not have “wp_force_remove_style” function defined. You have to have a function as following: function wp_force_remove_style() { // Do you stuff. }

displaying content that includes shortcodes within an echo

If some of your comments will contain shortcodes and some won’t, there’s no harm in running them all through do_shortcode(). If the content has no shortcodes in it, it will simply be returned, and if it does contain shortcodes, they’ll be parsed and the content returned. So you should be able to change echo ‘<span>’.$comment_content.'<br>’; … Read more