wp get post if a custom field has value - wordpress

am using WCK plugin for Custom Post Types and Fields
Its seems nice and i have done my work fine
One of my Custom Types has a custom field for upload an mp3 file
And now i want to get all the custom posts that have value for this mp3 field.
In other situations for example get all post that have thumbnail i use
'meta_key' => '_thumbnail_id'
Is there any similar approach to get the custom posts that have the mp3 field set.
UPDATE
Searching the db i noticed that there is a child post as attachment, so maybe its not a custom field problem and maybe i need to get the post that actually have attachment
Thanks

try use 'meta_key' => 'name_your_custom_field_for_mp3' You can see ACF documentation about this

Related

Mapping Ninja Form 'file upload' to custom field type 'file'

I have a Ninja Form that allows users to create a 'draft' post. The post is a custom post type that I created using CPT UI...it's called Resources. I used Advanced Custom Fields plugin to create the corresponding fields that should be receiving data from the Ninja Form submission. All fields are mapping correctly except the uploaded file. The file will get added to Media Library just fine, but don't get pulled into the post that the form submission created. If you use the post admin 'file' custom field to upload a file to the post, it works as you would expect it to. It's just that it won't recognize that i'm trying to send it a file from the Ninja Form. What am I missing?? I feel like this shouldn't require hacking to accomplish and i'm missing something fundamental. Thank you!!!

Write the content page 'Home' on the code or let the user customize it?

Let's say I have to code the page 'Home' of this site, what should I do as a programmer? Write the content in the template and if the user needs a modification make him call me or show the content by reading a specific posts of a determined category?
For example, create a category 'slideshow' and loop through it and add as many slides as posts are or a category 'why love us' and do the same?
How senior programmers in WordPress face this?
You have create one template as you say that will be home, Now if i am a developer for this site , i will divide this i.e.
Slider => May use plugin or custom post type.
Why Love Us => May be a custom filed is this is fixed in size, or may create custom post type
Our Teachers => Will be a custom post type.
Courses => Another custom post type
Testimonial => Another Custom post type
Gallery => It is easy to use plugin or wordpress built in media gallary
Blog => Will be popular or recent post
Other general things will be a theme options
So, you can manage your back-end like this so use can easily understood and easy to modify or update content.

WordPress Custom Post Type Issue

my situation is I registered a custom post type named 'products' and I included 'has_archive' => true in the parameter to enable an archive template for this custom post type, I also created a archive-products.php as the template for displaying post per taxonomy of 'products', but what I noticed is when I enabled 'has_archive' => true what happens is archive-products.php acts as the index page template of the 'products' custom post type instead of the 'page-products.php' file that I created as the index page template for listing all the post of 'products' custom post type.
then when I click a link to the product-category this archive-products.php uses the default archive.php as it's archive page template. it really acts weird and now I don't know what to do next.
what I want to happen is prevent this from happening and let page-products.php act as the default index page template for listing the posts (as it should be) and for archive-products.php to be used by page-products.php as it should be doing.
thanks I hope someone can help me into this issue.
by the way I'm using WordPress 3.5.1
I faced the same problem in the last days, and take a couple of hours to search for a solution, in my case the solution was to add this following functions to you functions.php file: flush_rewrite_rules(false);
I hope it can help you :)
you can check this plugin for your custom post display
wordpress.org/plugins/wp-custom-post-field
on here create your custom post and use shortcode for display post.

How to create Custom field in Custom Post-type

I've a custom post-type "video" and i enabled custom fields already.
i need to create three custom fields, 1. video file, 2. video url, 3. video code.
i tried couple of tutorials on tutsplus and other sites but not get working as i need.
anyone can help.
Wordpress has a built in api function, add_meta_box which you can use to output the form fields for your post meta. in the post_type argument you need to put 'video'
In order to capture the form input you need to use the save_post action, take a look here
Easiest way is to use a plugin like Advanced Custom Fields. You'll have a nice interface to add your custom fields and to choose on which post type to show them.

How to attach multiple files to a Wordpress post?

I'm currently working on a project where we are using Wordpress 3.0 RC. The idea is to create custom post types with meta boxes to make the system easier to use for the client. Some of these posts need to have multiple files attached to them, and by attached I do not mean inserted to post but rather we'd like to keep them separate from the post body (in fact, a given post type might not even have text, only files).
I'm wondering if there is a standard approach for allowing multiple files to be attached to a Wordpress post? I've managed to add a meta box that allows one file from the media library to be selected, but I have no idea how to extend this to allow an arbitrary number of files. Hope someone can help!
When a user is writing a post, and proceeds to upload media, that media is automatically 'attached' to the current post.
However, unless the user chooses to 'insert gallery', the media will not appear within the post, but it is still associated with the post.
You can get all media for a post using get_children() like so;
$media = get_children(array(
'post_parent' => $post_ID,
'post_type' => 'attachment'
));

Resources