WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Remove comma in custom field list (7 posts)

  1. venkmanuk
    Member
    Posted 3 years ago #

    Hi there,

    I'm trying to remove the comma in a custom field list.

    at the moment it says:

    Nowreading:
    book 1, book 2

    i want it to say:

    Nowreading:
    book 1
    book 2

    so remove the comma and replace with a <br />
    what's the code?

    thanks!

  2. Chip Bennett
    Theme Review Admin
    Posted 3 years ago #

    This is an impossible question to answer, with only the information you've given.

    What Theme are you using? Is the Theme adding the custom field, or is a Plugin adding the custom field? If a Plugin, what Plugin?

  3. venkmanuk
    Member
    Posted 3 years ago #

    its a custom theme i'm building.

    the custom field information is coming from <?php the_meta(); ?>
    no plugins..

    thanks for checking.

  4. Chip Bennett
    Theme Review Admin
    Posted 3 years ago #

    Then can you post the relevant code from your Theme into a pastebin?

  5. venkmanuk
    Member
    Posted 3 years ago #

    well, the code above is all i have.

    here's a pastebin explanation:
    http://wordpress.pastebin.com/AeA2wUCP

    i think i need to build a function somehow / somewhere that edits what the output is. ?

    cheers

  6. Chip Bennett
    Theme Review Admin
    Posted 3 years ago #

    You probably need to create a function that customizes your output, using get_post_meta(), and then creating markup using your meta_key values.

  7. venkmanuk
    Member
    Posted 3 years ago #

    yeah, here's the answer:

    you display the custom field as an array using get_post_meta and style the list. Here's the example that explained it to me.. just paste this in your page.

    assuming the custom field is called "thanks"

    < ?php
    $thanks = get_post_meta($post->ID, 'thanks', false);
    
    if ($thanks) {
      echo "<h3>Special thanks to:</h3>\n<ul>";
      foreach ($thanks as $person) {
        echo "<li>".$person."</li>";
      }
      echo "</ul>";
    }
    ?>

    credit goes here:
    http://www.boosten.org/using-custom-fields-in-wordpress-posts/

Topic Closed

This topic has been closed to new replies.

About this Topic