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

    (@dgold)

    One method is:

    Create your Table as an HTML table (if you really want it in a Table. If not then position everything with CSS divs).

    Where-ever you want the custom field value (your image) to appear (like say in the top-right box of your table), put the code as described here:
    https://codex.www.ads-software.com/Function_Reference/get_post_custom_values

    That will call-in your custom field value (say the custom field has the key “My Image” and the value is some HTML code for img src="my-image.jpg").

    Does that help?

    Thread Starter jungledsales

    (@jungledsales)

    Well sort of… except I don’t know how to call the custom fields from an entire category. I want to be able to add more posts and have this page automatically update and add more fields to the grid.

    Dgold

    (@dgold)

    Use the get_post_custom_values (that I linked instructions above)

    use it inside a Loop in your theme’s custom page template (modular-precasts-page-template.php), and it will keep adding for each post that the query picks up
    https://codex.www.ads-software.com/The_Loop

    If you want to limit it to a certain category, that’s another tweak on the query, but you could save that task until later. For now focus on pulling in allllll the posts that have your “Image For The Post” custom field regardless of category. Next, when you’re getting all the images, focus on pulling the Post Title that goes with each image. Next, focus on formatting your title + picture into the grid layout that you want (style, CSS, or table it). Finally, tweak your query if needed to limit the # that shows up, or the category it pulls from.

    I’m mainly able to describe this and give you the Codex links. My perspective is, you’ll have to do some studying and try different things. Make some progress, see what you can get to show up, and if you have a specific code question then post again with details.

    Thread Starter jungledsales

    (@jungledsales)

    Ok I got this working finally, but then I did an update to 2.6.5 and it broke. The code below was working and now it’s not. Any suggestions?

    <?php while (have_posts()) : the_post();
    			$thumb = get_post_meta($post->ID, 'Thumbnail', $single = true);
    			?>
    			<div id="grid">
    			<div class="productsgrid">
    				<h3 id="post-<?php the_ID(); ?>"><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h3>
    				    <?php
    					  	if($thumb !== '') { ?>
    						<a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>">
    					  	<img src="<?php echo $thumb; ?>"
    					  	class="grid-thumbnail-class"
    					  	alt="<?php if($thumb_alt !== '') { echo $thumb_alt; } else { echo the_title(); } ?>"
    					  	/>
    						</a>
    						<div style="clear:both;"></div>
    					  <?php }
    					  else { echo ''; } ?>
    			</div>
    			</div>

    I noticed you’ve accomplished this, and it looks great! Would you care to share the completed code here?

    I also wonder if you could use the get_the_image template tag instead of a custom field?

    Thanks if you can help:)

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Display custom field post data in grid’ is closed to new replies.