WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Problems using the_meta tag, custom fields, etc (5 posts)

  1. Prodromoi
    Member
    Posted 4 years ago #

    OK, I'll admit that I'm probably missing something very obvious, but I'm not a wiz at PHP...

    I'm experimenting with custom fields for the first time. I've added two different custom fields, each with it's own (different key) to a test post and updated the post so that it's saved.

    I've read the codex pages about the_meta tag and what needs to be done with it but I'm rather lost.

    Do I now need to add <?php the_meta(); ?> into one of the template files now? And if so, which one and where? I've seen reference to it needing to be in "The Loop" but I'm no closer to knowing quite where to find that...

    Can someone please offer idiotproof (or at least idiot-resistant) assistance as to what I now need to do to display the two custom fields after the post?

    Thanks in advance.
    A

  2. MichaelH
    Member
    Posted 4 years ago #

    Using the WordPress Default theme as an example, edit the wp-content/themes/default/index.php file and after this line:

    <p class="postmetadata"><?php the_tags('Tags: ', ', ', '<br />'); ?> Posted in <?php the_category(', ') ?> | <?php edit_post_link('Edit', '', ' | '); ?>  <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?></p>

    add

    <?php the_meta(); ?>

    Related:
    Stepping Into Template Tags
    Stepping Into Templates
    Template Hierarchy
    The Loop

  3. Prodromoi
    Member
    Posted 4 years ago #

    Ah, this may go some way towards explaining the problem. The template that I'm using (Suffusion 3.3.8) doesn't have that first line included in the index.php file at all. I've tried adding that whole line as well as the the_meta tag, but it's not got me any further.

    For info, the index.php of this template is:

    <?php
    /**
     * Core file required with every WP theme. We have files for everything else.
     * So this is essentially the landing page if nothing else is set.
     * This is also the file used for archives.
     *
     * @package Suffusion
     * @subpackage Templates
     */
    
    global $options;
    foreach ($options as $value) {
        if (get_option($value['id']) === FALSE) {
        	$$value['id'] = $value['std'];
        }
        else {
        	$$value['id'] = get_option($value['id']);
        }
    }
    get_header();
    ?>
    	<div id="main-col">
    <?php suffusion_before_begin_content(); ?>
    		<div id="content">
    <?php
    if ($suf_index_excerpt == 'list') {
    	include_once(TEMPLATEPATH . '/layouts/layout-list.php');
    }
    else if ($suf_index_excerpt == 'tiles') {
    	suffusion_after_begin_content();
    	include_once(TEMPLATEPATH . '/layouts/layout-tiles.php');
    }
    else {
    	suffusion_after_begin_content();
    	include_once(TEMPLATEPATH . '/layouts/layout-blog.php');
    }
    ?>
          </div><!-- content -->
        </div><!-- main col -->
    <?php
    get_footer();
    ?>
    
    <p class="postmetadata"><?php the_tags('Tags: ', ', ', '<br />'); ?> Posted in <?php the_category(', ') ?> | <?php edit_post_link('Edit', '', ' | '); ?>  <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?></p>
    <?php the_meta(); ?>

    ... where the last bit is, of course, the bit I added (and have now removed).

    Any other suggestions please?

    (Editing the default template as per your instructions works just fine!)

  4. MichaelH
    Member
    Posted 4 years ago #

    One possibility -- in the wp-content/themes/suffusion/layouts/layout-blog.php template after
    suffusion_content();
    put

    the_meta();
  5. Prodromoi
    Member
    Posted 4 years ago #

    Excellent, thank you. That's done it nicely.

    I also had to add the same line (at the same place) into the single.php file so that the custom fields were displayed on the single post pages too.

    Much obliged!
    A

Topic Closed

This topic has been closed to new replies.

About this Topic