Display PHP within HTML values

If the function returns a printed value: <a href=”https://wordpress.stackexchange.com/questions/145222/<?php bloginfo(“url’); ?>”>Link</a> If not (using the echo statement): <a href=”https://wordpress.stackexchange.com/questions/145222/<?php echo get_stylesheet_directory_uri(); ?>”>Link</a> You can also use print() as part of a more complex expression where echo cannot. By the contrary, when you want to use HTML into PHP, I recommend to close PHP and open … Read more

Problem with WordPress query on page using custom fields

Edit :// try this: <?php add_filter( ‘genesis_pre_get_option_site_layout’, ‘__genesis_return_full_width_content’ ); function sk_display_custom_fields() { /*Wordpress loop*/ global $wp_query; query_posts(array( ‘post_type’ => ‘sammenligne’ )); while(have_posts()) : the_post(); ?> $navn = get_field( ‘navn’ ); $type = get_field( ‘type’ ); echo ‘<p>’,$navn , ‘__’, ‘$type’,'</p>’); endwhile; wp_reset_query(); } add_action( ‘genesis_entry_header’, ‘sk_display_custom_fields’ ); genesis(); UPDATE:// Ok I tested ACF’s now. With … Read more

Any number in meta key (wp query)

You must use LIKE on the meta_key to support the SQL % pattern. The compare attribute only applies to the meta value. Instead you could try to filter it with: /** * Match any numbers in given a meta-key for WP_Query * * @see https://wordpress.stackexchange.com/a/177331/26350 */ ! is_admin() && add_filter( ‘posts_where’, function( $where ) { … Read more

Retrieve value of a category’s custom field

http://www.advancedcustomfields.com/resources/get-values-from-a-taxonomy-term/ prety much covers what you’re after I believe. So in your example while ( $projects->have_posts() ) { $projects->the_post(); $category_classes = array(); $categories = get_the_terms( get_the_ID(), ‘project_category’ ); if ( $categories ) { foreach ( $categories as $category ) { $categories_included[] = $category->term_id; $color = get_field(‘color’, ‘project_category_’.$category->term_id); } } You can also pass a term … Read more