Problem uploading different files as custom fields with front end post form

For starters, the ‘post_category’ argument only accepts category ID’s, so you will have to find that through your database, or through get_category_by_slug: $cat = get_category_by_slug( ‘music’ ); $cat_id = $cat->term_id; Secondly, look at your wp_handle_upload() section. You are passing $file[‘file’] in both cases, where ‘file’ is not the name of either of your upload fields. … Read more

Adding extra fields to front end signup form

You can read a somewhat extensive tutorial over at: http://www.cozmoslabs.com/1012-wordpress-user-registration-template-and-custom-user-profile-fields/ Basically this is what you’re going to be using to add them to the backend: add_action( ‘show_user_profile’, ‘show_extra_profile_fields’, 10 ); add_action( ‘edit_user_profile’, ‘show_extra_profile_fields’, 10 ); function show_extra_profile_fields( $user ) { ?> <input type=”text” name=”twitter” value=”<?php echo esc_attr( get_the_author_meta( ‘twitter’, $user->ID ) ); ?>” /> <?php … Read more

WP_Query () using taxonomy, custom post types

<?php $args = array( ‘post_type’ => ‘care-agency’, ‘meta_key’ => ‘wpcf-listtype’, ‘meta_value’ => ‘Enhanced Listing’ ); $loop = new WP_Query( $args); if ( $loop->have_posts() ) { while ( $loop->have_posts() ) : $loop->the_post(); //Here goes my loopy stuff endwhile; } All taken from the codex on WP_Query.

Fallback for empty custom fields

You could do it like this: // store post meta in a variable and use that so you aren’t pulling the post meta data twice $landPricing = get_post_meta($post->ID, “Pricing_Land_Only”, true) if(!empty($landPricing)) { echo $landPricing; } else { echo “Sorry, nothing was found.”; }

Custom field to array?

I will assume that you(or users) will enter post ids into a posts custom field, comma separated, eg: 11,13,34,54 OR 11, 13, 34, 54. Then all you need to do is get the custom field value for the loaded post, explode the custom field value by comma(,): and, then you’ll have a nice array to … Read more

custom comment_form fields not displaying

I think you’re a bit confused about how comment_form works. So let’s take a look (this is in wp-includes/comment-template.php): <?php function comment_form( $args = array(), $post_id = null ) { // snip snip $fields = array( ‘author’ => ‘<p class=”comment-form-author”>’ . ‘<label for=”author”>’ . __( ‘Name’ ) . ‘</label> ‘ . ( $req ? ‘<span … Read more

Automatic linking terms

The answer was right under my nose facepalm. In the custom field suite plugin, instead of entering ProductName-2000 : ProductName-2000 you enter <a href=”http://www.site.com/ProductName-2000/”>ProductName-2000</a> : ProductName-2000 I kinda wish i could delete this question… hope it helps someone else at least. 😛