Stripping and/or altering the content of a custom field (video URL)

Whipped up a nifty little parsing function for you: function wpse44048_parse_video_link( $link ) { $url=”some url”; // pass this in $parsed_url = parse_url( $url ); $host = $parsed_url[‘host’]; // check that the service exists, otherwise return false if( strpos( $host, ‘youtube.com’ ) !== false && strpos( $host, ‘youtu.be’ ) !== false && strpos( $host, ‘vimeo.com’ … Read more

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 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

plugin-list-category-post custom fields

You can use get_post_meta(). This is the codex article: http://codex.wordpress.org/Function_Reference/get_post_meta It sounds like each of the custom field values you want to display would only contain one result (one country, one town etc). In that case you’d use something like this in your template, wherever you want to display the value: <?php if ( get_post_meta($post->ID, … Read more