Two Questions on Custom Fields
-
I’m entering hour number six of this problem and have scoured the Internet searching for help. So I’m turning finally to the WP forum.
My website is https://www.reevolver.com
I’ll paste my current code below my quesions.1. I’ve got 5 custom fields that I want to show on posts of one specific category (see: https://www.reevolver.com/index.php/quests/loggerhead/02/homemade-butter-without-a-churn/ the 5 fields at the top of the post). I don’t have a problem adding those fields to each post I want them added to, but they’re showing up on all the posts and I can’t figure out how to keep them from appearing on posts I don’t want them on (such as: https://www.reevolver.com/index.php/reevolver/02/quest-hierarchy/).
2. For the fifth field I’ve got 5 .gifs that I have set, depending on whether I enter 1s, 2s, 3s, 4s, or 5s to display one of the 5 .gifs (It’s supposed to be a basic difficulty rating). And the .gif shows up, but only the 1s. I put in any of the other keys and still only the 1s shows up.
Hopefully someone can give me a clue. Code follows. Thanks.
<b><?php $my_custom_field = get_post_meta($post->ID, “Quest Title”, true);
echo “Quest Title: “.$my_custom_field.””; ?></b><?php $my_custom_field = get_post_meta($post->ID, “Discipline”, true);
echo “Discipline: “.$my_custom_field.””; ?>
<?php $my_custom_field = get_post_meta($post->ID, “Quest Level”, true);
echo “Hierarchal Rank: “.$my_custom_field.””; ?>
<?php $my_custom_field = get_post_meta($post->ID, “Quest Number”, true);
echo “Quest Designation: “.$my_custom_field.””; ?>
<?php $my_custom_field = get_post_meta($post->ID, “Difficulty”, true);
if($my_custom_field = “1s”) {
echo “Difficulty: “, ‘<img src=”/wp-content/uploads/2010/02/1S.gif”>’;
} elseif($my_custom_field = ‘2s’) {
echo “Difficulty: “, ‘<img src=”/wp-content/uploads/2010/02/2S.gif”>’;
} elseif($my_custom_field = ‘3s’) {
echo “Difficulty: “, ‘<img src=”/wp-content/uploads/2010/02/3S.gif”>’;
} elseif($my_custom_field = ‘4s’) {
echo “Difficulty: “, ‘<img src=”/wp-content/uploads/2010/02/4S.gif”>’;
} elseif($my_custom_field = ‘5s’) {
echo “Difficulty: “, ‘<img src=”/wp-content/uploads/2010/02/5S.gif”>’;
}; ?>
- The topic ‘Two Questions on Custom Fields’ is closed to new replies.