How do I customize the templates to match my theme?

I've tried adding single-classifieds.php to my theme directory, but it ends up spitting out errors like this:

FATAL ERROR: USING $THIS WHEN NOT IN OBJECT CONTEXT

Specifically for the get_expiration_date function. How would I get the expiration date in a custom template in my theme folder?

Also, the Posted By username doesn't show up in BuddyPress. I'm not sure if there are any other issues at this point, but if I could at least get this cleared up, I'm sure I can extrapolate the information I'll need to troubleshoot any additional issues I may run into.

Thanks.

  • Mike
    • New Recruit

    Hi @mbateam!

    Thanks for your question!

    I'm not a coder so I'm afraid I may not be able to answer these questions very well, however I can see from classifieds/ui-front/general/single-classifieds.php the code that you are talking about is this:

    <td><?php if ( class_exists('Classifieds_Core') ) echo Classifieds_Core::get_expiration_date( get_the_ID() ); ?></td>

    At the top of the single-classifieds.php file it says that you can override the file in your theme, it doesn't say to move it there.

    To replicate this I copied the single-classifieds.php to my theme folder and indeed received the same error as you did.

    What I then did was duplicate single.php and rename the duplicate single-classifieds.php

    Then in the code I added:

    Expiry date: <?php if ( class_exists('Classifieds_Core') ) echo Classifieds_Core::get_expiration_date( get_the_ID() ); ?>

    And the expiry date was shown on the page as you would expect. From what is there, for the buddypress username I think you would use:

    <a href="<?php echo bp_core_get_user_domain( get_the_author_meta('ID') ) . 'classifieds/';?>" alt="<?php the_author(); ?> Profile" ><?php echo $user->display_name; ?></a>

    Hopefully this is enough information to get you started, you can move things around and add things to your new single-classifieds.php file now to create your custom theme :slight_smile:

    Best Regards,
    Mike

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.