• Hi..

    i have some custom fields in articles.
    can i display them (from a specific category) as a table

    like: article title | customF | customF2 | …
    is this possible somehow?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Yes, it’s possible. First of all, you’ll want to create a custom category template for that category.

    https://codex.www.ads-software.com/Category_Templates

    Then, in the main loop of the category template, you can retrieve the article title and custom fields using code like this:

    <?php while (have_posts()) : the_post(); ?>
        <?php $postmeta = get_post_custom($post->ID); ?>
        <?php the_title(); ?>
        <?php echo $postmeta["CustomF1"][0]; ?>
        <?php echo $postmeta["CustomF2"][0]; ?>
        <?php echo $postmeta["CustomF3"][0]; ?>
        rest of loop code ...
    <?php endwhile; ?>

    It’s up to you how to structure the data. You could put it in an HTML table, or maybe use definition lists.

    I’ve done something similar on my plugins page. The plugin details (version, requirements, download link) are all stored as custom fields, and I’m pulling them into a custom category template using code very much like the sample I provided above.

    https://www.ambrosite.com/plugins

    Thread Starter dichterdichter

    (@dichterdichter)

    thats great. the idea of putting it in a category template is pefrfect.
    thank you very much.

    Thread Starter dichterdichter

    (@dichterdichter)

    another Problem.
    i changed the code to display the data as a Table, works great.
    but i have some custom fields using special characters
    like ?, ?, ü and it doesnt display any value.
    is this a problem of utf8 ?

    It could have something to do with the character set. Try deleting those special characters from the custom fields and see if it fixes the problem. Then you’ll know for sure.

    Thread Starter dichterdichter

    (@dichterdichter)

    can i escape them ? (if escape is the right thing to do)

    Edit: ok i found the error. it was a upload problem.
    as i edited the file in the theme editor of wordpress i just typed the special characters like ?,? and it worked.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Custom Fields with Article Title as Table ?’ is closed to new replies.