Add a field to just ONE page

Take a look at the Custom Field Template plugin. It supports adding specific custom fields based on various conditions, which range from broad to fine-grained. You can, for example, limit the display of a particular set of custom fields to a particular page id.

How to query posts by month based on date custom field?

It is not clear what you’re using as a comparison, but WP Query supports meta query comparisons and even has a DATE type. For example: $query = new WP_Query( array( ‘post_type’ => ‘attraction’, ‘meta_key’ => ‘attraction_date’, ‘meta_value’ => ’10’, ‘meta_compare’ => ‘LIKE’, ‘type’ => ‘DATE’ ) ); Using 10 is not going to get you … Read more

Create list from custom field comma separated values

foreach($items as $item) { $item = nl2br($item); list($name,$src,$price,$desc) = explode(‘<br />’,$item); echo “<div class=\”item\”>”; echo “<h2>$name</h2>”; echo “<img src=\””.trim($src).”\” />”; echo “<br />Price: $price”; echo “<br />Description: $desc”; echo “</div><br />”; } This works if you have them hit enter after each value to make the list. http://vudu.me/f7 Is an article I wrote, and it … Read more

Replacing custom field with shortcode

A shortcode like this [thumbnail height=100 width=100]http://urltoimage.com/image.jpg[/thumbnail] Would need this type of setup function content_insert_thumbnail($atts, $content = null){ global $post; extract($atts); $thumbnail = get_the_post_thumbnail($post->ID, array($height, $width)); $content .= $thumbnail; //Places the thumbnail after the content return $content; //Never echo a value from a shortcode function. } add_shortcode(‘thumbnail’, ‘content_insert_thumbnail’); To call this in your theme to … Read more

Show posts from category specified using a custom field

Finally solved it! I needed to add this at the end of each loop 🙂 <?php $my_query = new WP_Query(array( ‘category_name’ => get_post_meta($post->ID, ‘featured’, true), ‘posts_per_page’ => 5, )); if ($my_query->have_posts()): ?> <?php while ($my_query->have_posts()) : $my_query->the_post(); ?> content etc goes here <?php endwhile; ?> <?php endif; ?><?php wp_reset_query(); ?> many thanks James

Display custom field only if it has a value

<?php $metacatname = get_post_meta( $post->ID, ‘related blog articles’, true ); if(!(empty( $metacatname ))): $my_query = new WP_Query( array( ‘category_name’ => $meta_cat_name, ‘posts_per_page’ => 5, ) ); if ( $my_query->have_posts() ): while ( $my_query->have_posts() ) : $my_query->the_post(); ?> <a href=”https://wordpress.stackexchange.com/questions/29266/<?php the_permalink() ?>” rel=”bookmark” title=”<?php the_title(); ?>”><?php the_title(); ?></a> <?php endwhile; endif; endif; wp_reset_query(); ?>

Taxonomy or Custom Field

I’m not sure why an Author post-type has a “title” taxonomy, unless you meant books or something, or even why you can’t use the built-in published date field, but here goes: Store the date published as a timestamp in a custom field. You can do the conversions behind the scenes and just show users the … Read more