Skip Navigation

[Closed] Shortcode function not working with update to PHP 8

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

This topic contains 1 reply, has 2 voices.

Last updated by Christopher Amirian 1 year, 11 months ago.

Assisted by: Christopher Amirian.

Author
Posts
#2547451

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);
}

#2548277

Christopher Amirian
Supporter

Languages: English (English )

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.

The topic ‘[Closed] Shortcode function not working with update to PHP 8’ is closed to new replies.