Here's the code I've been using to a) format numbers; and b) count user posts. This worked until the update to PHP 8. Are there any changes required to keep this compatible or will these Toolset functions no longer work?
/**Add Toolset currency shortcode**/
function format_number( $atts ) {
extract( shortcode_atts( array(
'num' => '0'), $atts) );
return $num = number_format($num, 0);
}
add_shortcode('format_number', 'format_number');
/**Count number of listings**/
add_shortcode('listings-count', 'listing_count_func');
function listing_count_func()
{
$child_args = array(
'post_type' => 'listing',
'numberposts' => -1,
'post_status'=>'publish',
'order' => 'ASC',
'toolset_relationships' => array(
'role' => 'child',
'related_to' => get_the_ID(),
'relationship' => 'agent-listing'
)
);
$query = new WP_Query( $child_args );
$child_posts = $query->posts;
return count($child_posts);
}
Hi there,
The code in question does not use any Toolset functionality. Would you please enable WordPress "debug" mode and tell me what is the error that you get in PHP 8?
Would you please access your website files and edit the "wp-config.php" file on the root folder of your WordPress installation and add the code below into the file:
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', true );
Please add the code above the line below:
/* That's all, stop editing! Happy blogging. */
Thanks.