• Welcome to the all-new Kolakube support, the official place to get help for Marketers Delight, XFtoWP, CryptoWP, and other WordPress products! Please login with your account details to access private support forums.

Weird code behavior

Techsense

Member
XFtoWP
Messages
7
Reaction score
1
I added following custom field code to comment-lists.php, it works most of the time but occasionally fails. The same code was added to single-post.php and it works always fine. Is there any modification needed to get it work on the XFtoWP template?

PHP:
<?php echo get_post_meta($post->ID, 'custom', true); ?>
 
Solution
XFtoWP tries to avoid using global variables such as $post as it generally bad practice, so you will need to declare global $post; yourself in the template file or use a better approach for the post ID:

CSS:
$post_id = get_the_ID();

Alex

MD developer
Staff member
Md
XFtoWP
Messages
6,562
Reaction score
1,851
XFtoWP tries to avoid using global variables such as $post as it generally bad practice, so you will need to declare global $post; yourself in the template file or use a better approach for the post ID:

CSS:
$post_id = get_the_ID();
 
Comment
Solution
Top