Articles of custom field

How to exclude custom fields from search queries?

I’m building a hotel search engine and I’ve first created a custom content type “hotel” with Types & Views Toolset. I’m using “Search everything” plugin to query custom fields and custom taxonomy from this custom content and I’ve excluded the other content types from functions.php. For now, I have these custom fields : title address […]

Order custom fields alphabetically

I’ve been trying to order the custom fields alphabetically, but I can’t get the ordered list I want… this is the code I’m using: <?php $vMarca = get_field(‘tienda_marcas’ , false, false); $post_objects = get_posts(array( ‘post__in’ => $vMarca, ‘order’ => ‘ASC’ , ‘orderby’ => ‘title’ )); if($vMarca) { echo ‘<ul>’ ; foreach($vMarca as $post_objects) { echo […]

How to load php file for specific page in admin?

Hello and thanks for the guidance! Trying to load a custom .php file for only my home page (template is page-home.php) by using this code: add_action(‘admin_init’,’load_home_meta’); function load_home_meta() { global $pagenow, $post; if ($pagenow==’edit.php’ && ‘104’ == $post->ID) { include ‘metaboxes/home-meta.php’; } } The page’s unique ID is 104. I need this to work only […]

Add Custom Fields After Page Title

I want to add my custom fields after the page title when you view it on the site. How do I do this? PAGE TITLE [CUSTOM FIELDS HERE] PAGE CONTENT

Footnotes in custom fields

I am using Jquery Hover Footnotes plugin that allows adding footnotes and dynamically displays them on hover-over. In other words, I use {{FOOTNOTE_NUMBER}}, Then I embrace the actual footnote text with double brackets [[FOOTNOTE_NUMBER]] Footnote text [[FOOTNOTE_NUMBER]]. the plugin will find these “shortcodes” and auto place a box onhover on a footnote. For more information […]

Add a class to post_class if more than one post shares same meta_value_num

I would like to be able to add a class such as .samedate to posts that share the same meta_value_num from a custom meta box. So for example: Say two posts share the same custom meta box value for a date entered as 2013/11/03… If those two posts have the same meta value number, then […]

Importing from XML is ignoring serialized custom field

I have been trying to import something into a custom field using the WordPress Import tool but it seems to be leaving the custom field empty in the database. <wp:meta_value><![CDATA[a:19:{s:7:”address”;s:50:”52, St. Michaels Rd,Sheffield,S359YN”;s:11:”gpsLatitude”;s:18:””;s:12:”gpsLongitude”;s:18:””;s:18:”streetViewLatitude”;s:9:””;s:19:”streetViewLongitude”;s:18:””;s:17:”streetViewHeading”;s:17:””;s:15:”streetViewPitch”;s:18:””;s:14:”streetViewZoom”;s:1:”0″;s:9:”telephone”;s:13:”01142570288″;s:5:”email”;s:19:””;s:3:”web”;s:17:””;s:11:”hoursMonday”;s:9:””;s:12:”hoursTuesday”;s:9:””;s:14:”hoursWednesday”;s:9:””;s:13:”hoursThursday”;s:9:””;s:11:”hoursFriday”;s:9:””;s:13:”hoursSaturday”;s:6:””;s:11:”hoursSunday”;s:6:””;s:18:”alternativeContent”;s:0:””;}]]></wp:meta_value> There doesn’t seem to be anything massive sticking out with this, but when I use the importer tool it ignores this and […]

Collect Data from NEXT item while in loop

I am trying to get the value of a custom field. The trick? I’m in the loop, currently printing out 2 of 5 for this example. I would like to get some info from 3 of 5 (or even 1 of 5) while printing out info on 2 of 5. I hope that makes sense. […]

Sorting posts by custom field value in array

I have a custom field value that is an array and it has date as one of the values: a:3:{s:4:”date”;s:10:”03/06/2013″;s:6:”target”;d:1000;s:8:”currency”;s:3:”USD”;} I’m trying to sort posts with this date but I’m having trouble doing it. Here is my query: $args = array ( ‘showposts’ => -1, ‘post_type’ => ‘project’, ‘orderby’ => ‘meta_value’, ‘order’ => ‘ASC’, ‘meta_query’ […]

Display Custom Field in Sidebar if Value is Present

I’m trying to use ‘if’ ‘else’ to display a link button if I have a value in the ‘TourURL’ custom field, and if not, nothing will display but can’t seem to get the if code to work: <?php if(global $wp_query; $postid = $wp_query->post->ID; echo get_post_meta($postid, ‘TourURL’, true); wp_reset_query(); ): ?> <P>Show Link</P> <?php else : […]