Populate wordpress menu with link to custom field value (file download)

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

How do I list a custom field and custom taxonomies for each result in a loop?

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

How show post only from after custom date

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

Multiple Custom Field Query

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