• Hi
    can anyone help me with an issue regarding custom fields.

    I have a file about.php called from sidebar.
    Here is the code:

    <!--about-->
     	<div id="about">
        <?php query_posts('pagename=about'); ?> 
    
        <?php while (have_posts()) : the_post(); $myphoto = get_post_meta($post->ID, "myphoto", TRUE); $mydesc = get_post_meta($post->ID, "mydesc", TRUE); ?>
    
        <h3>About Me</h3>
      	<a href="<?php the_permalink() ?>"><img src="<?php echo $myphoto; ?>" alt="<?php bloginfo('blogname'); ?>" title="<?php bloginfo('blogname'); ?>" /></a><span><?php echo $mydesc ;?></span>
      	</div><!--about-end-->      
    
    	<?php endwhile; ?>

    the custom fields keys are written directly in the file. I got these instructions from a tutorial.

    I cant figure out what I need to add into the custom fields to get the content to display.
    So far I uploaded an image using the media library, then I created a post, then I added a custom field name “mydesc” and entered the permalink url to the new post as the value for the custom field.
    I then added another custom field,name “myphoto” and entered the url to that image as the value (directly pasted in both cases).
    The about.php code is present on every page but the content isnt showing.
    can anyone give some advice?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Give this a shot

    <!--about-->
    <div id="about">
    	<?php
    		$page = get_page_by_title('about');
    		$myphoto = get_post_meta($page->ID, 'myphoto', TRUE);
    		$mydesc = get_post_meta($page->ID, 'mydesc', TRUE);
    	?>
    	<h3>About Me</h3>
    	<a href="<?php echo get_permalink($page->ID) ?>"><img src="<?= $myphoto; ?>" alt="<?php bloginfo('blogname'); ?>" title="<?php bloginfo('blogname'); ?>" /></a>
    	<span><?= $mydesc ;?></span>
    </div>
    <!--about-end-->
    Thread Starter sambkk

    (@sambkk)

    Hi
    thank you for the advice.

    unfortunately I didnt work, i got a parse error.

    I can get the image to display ok by coding the image path in directly

    but I still have no idea how t get this to work as its supposed to 🙁

    Can you post a link for me to see?

    Thread Starter sambkk

    (@sambkk)

    Hi
    I really appreciate you trying to help me.
    unfortunately the build is on my local machine.
    here is a link to the tutorial I was following:
    Word press tutorial
    It just leaves a few issues open, otherwise I found it ver helpful. Anyway my about.php is from there,
    Thanks again.

    Thread Starter sambkk

    (@sambkk)

    thanks for the help tjeasmond
    I figured it out by myself, just took a little studying about what custom fields are

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘custom fields problem’ is closed to new replies.