Conditionally call multiple custom field entries for a post?
-
Hi guys. I would like to know how to conditionally fetch and echo custom field entries for a single post, if the post is in a specific category.
Let me explain what I’ve done already.
I have a conditional PHP if statement in my sidebar.php that reads as follows.
<?php if ( is_single() && in_category('creative-writing') ) : ;?> <div id="floater"> <div class="floating-excerpt"><?php the_excerpt(); ?></div> </div> <?php endif; ?>
This works great. On single posts in the “creative-writing” category, the_excerpt is inserted into a div and floated off to the side as a sort of pull-quote. I use a manually created excerpt for each post in this category.
What I want to do now is to switch from using one excerpt per post, to using several hand-crafted excerpts that I will manually input into custom fields. If possible, I would also like to insert some markup between each iteration of the custom field. It should be flexible to allow for any number of custom field entries, though they will all have the same key (call it $pullquote).
How would I go about this?
(BTW, I’m aware that there’s a pull quote plugin, but I’d prefer to do it this way.)
- The topic ‘Conditionally call multiple custom field entries for a post?’ is closed to new replies.