Articles of custom field

Underscores in custom fields

While trying to perform a WP_Query using meta_query(), I had some trouble because the custom fields created by a plugin had _ in the beginning of its name. Although I noticed it was stored this way in the database, I had no idea why it was there and thought I had to reference it without […]

Can I query custom meta data through WP_Query

Ok, my question is a bit complex so I will try and give a general explanation and then go into details afterward. I am running WordPress 3.4.2 and I am using WCK Post Type Creator and WCK Custom Fields Creator to create my custom post type and custom fields. I am trying to query posts […]

How to add a checkbox element to attachments editor with example

The code below adds a custom input field to the attachments editor. How can I convert the text input to a checkbox and get/set the value of the checkbox on load and save? Note: “input” => “checkbox” does not work 🙁 function image_attachment_fields_to_edit($form_fields, $post) { $form_fields[“imageLinksTo”] = array( “label” => __(“Image Links To”), “input” => […]

Filter WP_Query for posts having a certain meta-value

How to filter WP_Query for posts having a certain meta-value, without using a Custom Select Query? I have a custom posttype with meta-key: “open”, and meta-value options: “yes” or “no”. I would like to show posts only with meta_value = yes, for meta_key = “open”. function filter_where($where = ”) { $open = “yes”; //$where .= […]

Orderby meta_value only returns posts that have existing meta_key

I have the following wp_query: $args = array( ‘post_type’ => ‘news’, ‘orderby’ => ‘meta_key’, ‘order’ => ‘ASC’, ‘meta_key’=>’custom_author_name’, ‘post_per_page’=>-1 ); $query = new WP_Query($args); echo $query->found_posts; echo = 10 results because there are only 10 news posts with a meta_key = custom_author_name. But there are hundreds of news posts that don’t have a post_meta row […]

What is “meta_input” parameter in wp_insert_post() used for?

I am inserting some post into wordpress using the function wp_insert_post(). I want to insert some custom fields on each post and reading the documentation I though the meta_info parameter was used for that, I tried something like this: $data = array( ‘post_author’ => 1, ‘post_status’ => ‘publish’, ‘post_title’ => $post->getTitle(), ‘post_content’ => $post->getContent(), ‘post_category’ […]

Importing data for advanced custom fields plugin?

I have a member section built using the http://www.advancedcustomfields.com plugin. There are 300 members that each have the following data: Company name Specialism (check boxes) Web address Telephone number Region Address Email What’s the best way to import into the database? How should I setup a csv file? I haven’t added the 300 member pages, […]

Individual Widgets per Page

In my (page-only, no posts) WordPress site I have a number of static blobs in need to put in a sidebar. We could call/tream thoses ‘blobs’ as widgets. At least they’ll have a fixed html content, like ‘teaser1’, ‘teaser2’, ‘disclaimer’, ‘foo policy’… What I need, is to arrange them differently for every page. So this […]

How to correctly call custom field dates into a posts_where filter using SQL statements

Currently I have the loop listing posts between two dates using the posts_where filter: function filter_where( $where = ” ) { $where .= ” AND post_date >= ‘2000-01-01′ AND post_date <= 2004-12-31’ “; return where; } add_filter(‘posts_where’, ‘filter_where’); query_posts($query_string); while (have_posts()) : the_post(); the_content(); endwhile; In a meta_key called original_date I have stored a different […]

Custom Post Types: How-to get rid of editor (-meta box)

I’m questioning how i can get rid of the post-editor (visual + html). I tried to not register post type support, and it still appears (de-registering works fine with every other default meta box on post edit screen). I also tried to deregister it with remove_meta_box, which didn’t work too (works for everything else except […]