Page 2 of 2 FirstFirst 12
Results 11 to 18 of 18

Thread: Custom Field?

  1. #11
    kyle is offline Hello World
    Join Date
    Nov 2009
    Posts
    16

    Default

    You might have to echo restlist as an array by doing this:

    PHP Code:
    echo '<li><a href="' get_the_permalink() . '">' $customPostID['restlist'][0] . '</a></li>'

  2. #12
    ScottHack's Avatar
    ScottHack is offline Hello World
    Join Date
    Nov 2009
    Posts
    27

    Default

    Kyle,

    Tried your code and I at least got an error message this time!

    Parse error: syntax error, unexpected T_IF -- says the error is on line 17.

    Code:
    <?php
    /*
    Template Name: Rest List
    */
    ?>
    
    <?php get_header(); ?>
    
    <div id="content">
    
        <div id="contentleft">
    <ul>
     <?php
      $postslist = get_posts('numberposts=-1&order=ASC&orderby=title');
     foreach ($postslist as $post) : 
    $customPostID = get_post_custom($post->ID)
    if(isset($customPostID['restlist'])) :
        setup_postdata($post);
    echo '<li><a href="' . get_the_permalink() . '">' . $customPostID['restlist'] . '</a></li>';
    endif;
    endforeach;  
    ?>
    </ul>    
            
        
        </div>
        
    <?php include(TEMPLATEPATH."/sidebar_right_page.php");?>
        
    </div>
    
    <!-- The main column ends  -->
    
    <?php get_footer(); ?>

  3. #13
    reLoadedThemes is offline Hello World
    Join Date
    Nov 2009
    Posts
    8

    Default

    Add a semicolon at the end on
    $customPostID = get_post_custom($post->ID);
    We reLoad™ Premium WordPress themes

  4. #14
    kyle is offline Hello World
    Join Date
    Nov 2009
    Posts
    16

    Default

    Sorry ScottHack, I realized the error when I decided to test it on my own install, but then forgot to add it back in. Just add the semi-colon as reLoadedThemes suggests.

  5. #15
    ScottHack's Avatar
    ScottHack is offline Hello World
    Join Date
    Nov 2009
    Posts
    27

    Default

    That brings me back to just a blank page with no code able to be viewed.

  6. #16
    ScottHack's Avatar
    ScottHack is offline Hello World
    Join Date
    Nov 2009
    Posts
    27

    Default

    Getting closer.

    This code now loads. Gives no errors. However, instead of it using the custom field meta data as the anchor text, it puts "Array"

    Help!

    Code:
    <?php
    /*
    Template Name: Rest List
    */
    ?>
    
    <?php get_header(); ?>
    
    <div id="content">
    
    	<div id="contentleft">
    <ul>
     <?php
      $postslist = get_posts('numberposts=-1&order=ASC&orderby=title&meta_key=restlist');
     foreach ($postslist as $post) :
    $customPostID = get_post_custom($post->ID);
    if(isset($customPostID['restlist'])) :
        setup_postdata($post);
    echo '<li><a href="' . get_permalink() . '">' . $customPostID['restlist'] . '</a></li>';
    endif;
    endforeach;
    ?>
    </ul>	
    
    	</div>
    
    <?php include(TEMPLATEPATH."/sidebar_right_page.php");?>
    
    </div>
    
    <!-- The main column ends  -->
    
    <?php get_footer(); ?>

  7. #17
    reLoadedThemes is offline Hello World
    Join Date
    Nov 2009
    Posts
    8

    Default

    Quote Originally Posted by ScottHack View Post
    Getting closer.

    This code now loads. Gives no errors. However, instead of it using the custom field meta data as the anchor text, it puts "Array"

    Help!

    Code:
    <?php
    /*
    Template Name: Rest List
    */
    ?>
    
    <?php get_header(); ?>
    
    <div id="content">
    
    	<div id="contentleft">
    <ul>
     <?php
      $postslist = get_posts('numberposts=-1&order=ASC&orderby=title&meta_key=restlist');
     foreach ($postslist as $post) :
    $customPostID = get_post_custom($post->ID);
    if(isset($customPostID['restlist'])) :
        setup_postdata($post);
    echo '<li><a href="' . get_permalink() . '">' . $customPostID['restlist'] . '</a></li>';
    endif;
    endforeach;
    ?>
    </ul>	
    
    	</div>
    
    <?php include(TEMPLATEPATH."/sidebar_right_page.php");?>
    
    </div>
    
    <!-- The main column ends  -->
    
    <?php get_footer(); ?>
    Try
    PHP Code:
    echo '<li><a href="' get_permalink() . '">' $customPostID['restlist'][0] . '</a></li>'
    We reLoad™ Premium WordPress themes

  8. #18
    ScottHack's Avatar
    ScottHack is offline Hello World
    Join Date
    Nov 2009
    Posts
    27

    Default

    Woohoo! Thanks reLoad!

Page 2 of 2 FirstFirst 12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •