How to show content of custom fields in search results?
Something along the lines of get_post_custom() or get_post_meta() probably would suit your needs pretty well. You can feed either of them with get_the_ID() for the $post_id.
Something along the lines of get_post_custom() or get_post_meta() probably would suit your needs pretty well. You can feed either of them with get_the_ID() for the $post_id.
Try this: // Filter wp_nav_menu() to add additional links and other output add_filter(‘wp_nav_menu_items’,’add_pdf_to_menu’, 10, 2); function add_pdf_to_menu( $items, $args ) { if( $args->theme_location == ‘extra-menu’) { $pdf = get_post_meta( get_the_ID(), ‘mcf_uppsagning-pdf’, true ); if ( $pdf ) $items .= ‘<li><a href=”‘ . wp_get_attachment_url( $pdf ) . ‘”>Uppsägning</a></li>’; } return $items; } Essentially because you’re in … Read more
You can get custom field values with get_post_meta. Like so… <?php $wp_query = new WP_Query(); $wp_query->query(‘post_type=customtype&showposts=10′.’&paged=’.$paged); while ($wp_query->have_posts()) : $wp_query->the_post(); the_title(); // <- works if( $some_meta = get_post_meta( get_the_ID(), ‘the_meta_key_you_want’, true ) { // you could put other formatting here. echo $some_meta; } endwhile; You’ll need to change the_meta_key_you_want in the call to get_post_meta, of … Read more
You can certainly use the Advanced Fields plugin for this type of functionality – you’ll just need to add a few lines to the query that creates your custom pages. I found the documentation on checkboxes from ACF to be helpful. Scroll through the code examples at the bottom of the page and you’ll see … Read more
Here the trick 😀 Replace line 145 tb_show(”, ‘media-upload.php?type=image&TB_iframe=true’); with tb_show(”, ‘media-upload.php?post_id=1&type=image&TB_iframe=true’); Manh
You can do this using query_posts() or a new WP_Query object. Here’s an example: query_posts( array( ‘post_type’ => ‘my_post_type’, ‘meta_query’ => array( array( ‘key’ => ‘my_date_field_key’, ‘value’ => date( ‘d/m/Y’ ), ‘compare’ => ‘<‘, ‘type’ => ‘DATE’ ) ) ) ); if ( have_posts() ) : while( have_posts() ) : the_post(); // your loop code … Read more
that should be fairly simple using Meta_Query parameter of the WP_Query object you can set the relation and set as many fields as you like: $args = array( ‘meta_query’ => array( ‘relation’ => ‘OR’, //realation array( ‘key’ => ‘color’, //first custom field ‘value’ => ‘blue’, ‘compare’ => ‘NOT LIKE’ ), array( ‘key’ => ‘price’, //second … Read more
When I was working on the same the issue was that when you try to add custom meta box before the post is created it did not work. So what I did was once the post was created added the following code $imagepath = wp_get_attachment_image_src( $upload[1], $size ); update_post_meta($post_id, ‘image_path’, $imagepath[0]; So what happen’s here … Read more
Change above code to like this: <?php $cast_members = get_post_meta($post->post_parent, ‘cast_members’, true); ?> <p><?php echo wpautop($cast_members); ?></p> <?php endif; ?> in this code wpautop() function automatically adds p tag for cast members.
Your example is a bit hard to understand, as it seems to query for meta_values of X,Y,Z,AB,ID,IA. I hope you can still make sense of the below posted code: // query posts that have on of the custom values for the custom meta key ‘my_key’ // and/or one of the custom meta values for the … Read more