WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Displaying a Custom Field in a Page (7 posts)

  1. funkton
    Member
    Posted 4 years ago #

    Hi

    I have this but it is not working as I assume because it is not in the loop? Help?

    <?php
    /*
    Template Name: Whatever
    */
    ?>
    
    <html>
    <head>
    <title>Demo Template</title>
    
    <link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>">
    
    </head>
    
    <body>
    
    <div id="wrapper">
    
    	<div id="photo">
    
    		<img src="HannahDeCanchoGREEN.jpg" alt="Klematis" width="300" height="446" />
    
    	</div>
    
    	<div id="textblock">
    
    		<p> <?php the_meta(); ?> </p>
    
    	</div>
    </div>
  2. shua
    Member
    Posted 4 years ago #

    put it in the loop

  3. funkton
    Member
    Posted 4 years ago #

    what just the

    <p> <?php the_meta(); ?> </p>

    bit??

  4. funkton
    Member
    Posted 4 years ago #

    got it!!

    <?php if (have_posts()) : ?>
                   		<?php while (have_posts()) : the_post(); ?>
                   			<!-- do stuff ... -->
    				<?php the_meta(); ?>
    				<?php the_time('l, F jS, Y') ?>
    
                   		<?php endwhile; ?>
    		<?php endif; ?>

    excellent thanks!

  5. funkton
    Member
    Posted 4 years ago #

    how do i remove the name of the custom field from displaying?

  6. shua
    Member
    Posted 4 years ago #

    i use: Get Custom Field Values

    here is what some of my code looks like:

    <?php query_posts('category_name=board-of-directors&order=asc');
         	while (have_posts()) : the_post();
        	$do_not_duplicate = $post->ID; ?>
        	<div>
    		<h3><?php the_title(); ?> <span><?php echo c2c_get_custom('boardTitle'); ?></span></h3>
    		<p><?php the_content() ?></p>
    	</div>
    <?php endwhile; ?>

    this loops thru my board of directors, displays their Name (title) their Title on the board (boardTitle as a custom field), and their bio (content)

    hope this helps

  7. funkton
    Member
    Posted 4 years ago #

    Yes it did!

    I did this

    <?php if (have_posts()) : ?>
                   		<?php while (have_posts()) : the_post(); ?>
                   			<!-- do stuff ... -->
    
    				<p> <?php echo get_post_meta($post->ID, 'TextBox', true) ?> </p>
    				<p> <?php echo get_post_meta($post->ID, 'TextBox2', true) ?> </p>
    				<p> <?php echo get_post_meta($post->ID, 'TextBox3', true) ?> </p>
    				<p> <?php echo get_post_meta($post->ID, 'TextBox4', true) ?> </p>
    				<p> <?php the_time('l, F jS, Y') ?> </p>
    
                   		<?php endwhile; ?>
    		<?php endif; ?>

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.