Display Custom Field in Sidebar if Value is Present

I think, you’re mistaken in how if works…? $post_meta = get_post_meta( $GLOBALS[‘wp_query’]->post->ID, ‘TourURL’, true ); if (! empty($post_meta)) echo ‘<p>Show Link</p>’; else echo ‘<p>No Link</p>’; This should do what you want – if I understood you correctly. // UPDATED

How to exclude custom fields from search queries?

If I understand you correctly, you need to have post metas in your query. This is where the meta_query parameter of the WP_Query class comes to help. The meta_query is an array of arrays. Example from the codex: $args = array( ‘post_type’ => ‘my_custom_post_type’, ‘meta_key’ => ‘age’, ‘orderby’ => ‘meta_value_num’, ‘order’ => ‘ASC’, ‘meta_query’ => … Read more

Order custom fields alphabetically

It looks like you’re trying to output the wrong stuff. You’ve ordered the $post_objects, not the $vMarca. Try using the $post_objects variable for your if and foreach statements thus: <?php $vMarca = get_field(‘tienda_marcas’ , false, false); $post_objects = get_posts(array( ‘post__in’ => $vMarca, ‘order’ => ‘ASC’ , ‘orderby’ => ‘title’ )); if($post_objects) { echo ‘<ul>’ ; … Read more

Collect Data from NEXT item while in loop

As you posted no code and little in the way of exactly what criteria you are using, I can’t really writ functioning code but inside your Loop try: var_dump($posts[$wp_query->current_post -1]->post_title); That is, $posts[$wp_query->current_post -1] is the previous post. You can change -1 to plus or minus whatever value you want but the math cannot result … Read more

Custom field Search with Relavanssi

I don’t have Relevansii installed but it looks like you can hook to relevanssi_search_ok and return false, and Relevansii will pass back the unmodified search. add_filter(‘relevanssi_search_ok’, ‘__return_false’); I am going to assume that Relevansii is using the ordinary search form provided by the theme, meaning that you could modify, or create, searchform.php to include the … Read more

Display Posts Query with IF function

If I understand you, you want to filter out faculty members who do not have any awards at the query stage. Replace your code: <?php query_posts( ‘post_type=mtt_page’); ?> <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?> with this (untested): <?php $args = array( ‘post_type’ => ‘mtt_page’, ‘posts_per_page’ => -1, ‘meta_query’ => … Read more

Insert custom fields to a custom post type

That statement grabs a file called content-post-format.php in the theme directory, depending on the post format. Posts will grab content.php since there is no post format. Copy the information out of content.php into single-campsite.php and go from there. Alternatively, you can create a copy of content.php called content-campsite.php and call: <?php get_template_part( ‘content’, ‘campsite’ ); … Read more