• Hi,

    I’ve created a custom field “memory_name” to display a name (surprise!). When I try to display this field in a post template using:
    <?php echo get_post_meta($post->ID, "memory_name", true); ?>
    it works fine and displays properly.

    However, I’m trying to insert this field into a plugin’s template using:
    <p class="post-date-timeline">'.get_post_meta($post->ID, "memory_name", true).'\'s memory from '.get_the_date().'</p>

    The plugin is “Timeline Ultimate” and I’ve posted there, but then wondered if there was something general I would need to maybe register the custom field in the plugin? get_the_date also works perfectly everywhere.

    Thanks.

Viewing 7 replies - 1 through 7 (of 7 total)
  • I’d try populating a $Var first and then use that $Var in the class name line.

    Thread Starter mherbert

    (@mherbert)

    Hi Radices, I’m not having any success with that either. It’s weird.

    Would you put the $Var in the plugin’s code, or would you add it to a functions.php? I guess it’s not really a function and not needed anywhere else, other than the plugin.

    Thread Starter mherbert

    (@mherbert)

    PS. Should say that I’m no expert, so there is the potential for a stupid mistake!

    I’d put it in the plugin’s template code . Right above where you want to use it.

    <?php $mem_name = get_post_meta($post->ID, "memory_name", true); ?>
    
    <p class="post-date-timeline">'.<php? $mem_name ?>.'\'s memory from '.get_the_date().'</p>

    I’m a hacker myself … just spit balling with you to try and help. Pretty sure you need to wrap the get_the_date in php tags as well.

    Thread Starter mherbert

    (@mherbert)

    I don’t want to take up any more of your time, although I do really appreciate it. I have a feeling it’s something to do with the plugin that is making it fail as “standard” wordpress functions (get_the_author, get_the_date) are all working fine.

    What I’m doing… We’re building a community website and we want to build a timeline of people’s memories. I don’t want them to have to create an account (I don’t think they would bother), but instead there’s a front end form that creates a post when submitted. Because I want the contributor’s name to be displayed, rather than the author’s, I use a custom field to collect that. All that side works, it’s just displaying it in the plugin. As I say, the custom field displays fine everywhere except the one place I need it!

    As a hacker, can you think of a workaround where I can take a name and have it display as the post author without registration, or do you think I’m going about it the right way?!

    As I said before, thanks again for looking.

    Thread Starter mherbert

    (@mherbert)

    I found a solution here.

    Does the job perfectly! Once again, thanks for your help though.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Displaying Custom Fields Issue’ is closed to new replies.