Filter by custom field (meta_key) using JSON API

As this is too much for a comment, I’ll post here and delete later: http://example.org // domain ?json=get_recent_posts // controller # Arguments for the query start here &post_type=mytype &custom_fields=myfield &include=title,custom_fields &meta_key=myfield &meta_value=myvalue Have you tried the following? Debug the response: http://www.example.org/api/get_page_index/?dev=1 Widget-style JSONP output: http://www.example.org/api/get_recent_posts/?callback=show_posts_widget&read_more=More&count=3 Redirect on error: http://www.example.org/api/posts/create_post/?callback_error=http%3A%2F%2Fwww.example.org%2Fhelp.html And could you post what you … Read more

List taxonomy term “Last Name” + “First Name” (taxonomy custom field) in a post loop

So I decided to go another way. I now have the Author’s Full Name as terms in the taxonomy. For the index, for which I need to separate Last Name and First Name, I used PHP string functions. <?php $taxonomy = ‘autores’; $queried_term = get_query_var($taxonomy); $terms = get_terms($taxonomy, ‘slug=’.$queried_term); if ($terms) { echo ‘<div id=”indiceAutores-nav”></div> … Read more

Show values of dynamically created custom meta keys

This completely untested, but something like this should work. It assumes that the dates come in before (start and end) – this should have been verified when the data was processed. $i=1; $key_start=”available_dates_from_”; $key_end = ‘available_dates_to_’; echo ‘<ul>’; while($start = get_post_meta($post_id, $key_start.$i, true)){ $end = get_post_meta($post_id, $key_end.$i, true); echo ‘<li> From ‘.$start. ‘ until ‘.$end.'</li>’; … Read more

Create an Array of Specific Custom Post Meta

If I’m understanding your issue correctly, and if by ‘project title’ you mean the content of the post_title field, then it’ll look something like this: $post_data = array(); $my_query = new WP_Query( $whatever_your_args_are ); if ( $my_query->have_posts() ) { while ( $my_query->have_posts() ) { $my_query->the_post(); $post_data[] = array( ‘project_title’ => get_the_title(), ‘latitude’ => get_post_meta( get_the_ID(), … Read more

How do i save and retrieve custom attachment meta?

The field id has to match in both function so if your field id is foo the when you save you need to look for that id and when you save a checkbox field its smart to remove it if not set so: function image_attachment_fields_to_save($post, $attachment) { if( isset($attachment[‘foo’]) ){ update_post_meta($post[‘ID’], ‘foo’, $attachment[‘foo’]); }else{ delete_post_meta($post[‘ID’], … Read more

How to stick custom post at the top in search results

A simple hack. Edit: putting the featured post ids in an array and checking that array in the main loop. global $post; $post_IDs = array(); foreach($post_info as $post_info_obj) { $post_IDs[] = $post_info_obj->ID; } $featured_IDs = array(); $query1 = new WP_Query(array(‘meta_key’=>’sticky’,’meta_value’=>’featured’,’post__in’=>$post_IDs)); while($query1->have_posts()) { $query1->the_post(); $featured_IDs[] = $post->ID; get_property_info_li($post); } First thing do to in the main … Read more