Tag Info

New answers tagged

0

I Found my mistake. Basically, I had a bad prefix... I changed the function name of the get_post_meta to $gwrrest_stored_meta but then missed it in the echo of the text area content. I had "recycled" my code and accidentally left is as $prfx_stored_meta. So the line here: <textarea name="specials-textarea" id="specials-textarea"><?php if ( ...


1

I looks like you are using the custom meta boxes and fields github repo, which is an awesome library. I think the primary thing you need to do is a new WP_Query. Below is an example of that in action. The only difference is that in my example I made the "Assign to Homepage" a checkbox on the custom post type. <?php $args = array( 'post_type' => ...


1

I'm not clear on how your code works as-is, as I mentioned in my comment. It looks like you're adding an action to call a function inside the function that you want to call with that action. If nothing outside the function invokes it, it never runs. add_action( 'template_redirect', 'check_breadcrumb_condition' ); function check_breadcrumb_condition(){ ...


1

You can do this by adding the following class in your theme for admin options; Custom-Metaboxes-and-Fields-for-WordPress And you can call your repeatable fields with some thing like this; array( 'name' => 'Name of field', 'id' => 'prefix_option_name', 'type' => 'text', 'default' => '', ...


0

Yes, you'll want to create custom metaboxes for those. This is a pretty good intro into how to do that. But you might want to think through a few things: Are you sure you want that added to ALL posts? If not, perhaps create a custom post type and attach those fields to that post type instead. Maybe you really DO want it on Posts and not a Custom Post Type, ...


0

You can use PHP's fgetcsv() or str_getcsv() function to parse the uploaded CSV file. Your CSV will need to include a column with the Post's ID as well as the columns matching up to your custom field names. Loop through the CSV and for each line update the custom fields for that post using update_post_meta() http://php.net/manual/en/function.fgetcsv.php ...


5

By default, WP_Query returns the standard WP_Post objects for the posts being queried. I believe with some clever rewrite and use of the filters given in WP_Query you can add objects to the returned WP_Post objects array. Will this be performant. In my opinion, I will hurt performance more as you will need to join results in your query as custom fields are ...


0

Hey Please try this one I think it work fine. $args = array( 'post_type' => 'page', 'meta_key' => 'someMetaKeyName', 'meta_query' => array( array( 'key' => 'someMetaKeyName', 'type' => 'CHAR', ), ), ); ...


1

More or less you got two decision points here. Are “types” of work items CPTs or terms of taxonomy? While from the start it sounds more like terms (they are all work items, but of different types) the latter requirement of different fields brings them closer to multiple CPTs in my opinion. I don't think this is clear cut here, either could work. ...


1

By using get_post_meta() fetch the custom field data $key_value = get_post_meta( get_the_ID(), 'key', true ); // check if the custom field has a value if( ! empty( $key_value ) ) { echo $key_value; } also see for more detail get_post_meta()


1

See get_post_meta() Example: get_post_meta($post->ID, 'EXAMPLEFIELD', true);


0

Your problem is that you are putting the page result in $page. While the normal commands like the_title() and get_field() will look for the $post variable if you are not setting a seperate ID of which you want the title. I once did this by creating a backup of the $post variable, and then just put each post i wanted to include on the parent page in the ...


1

Use the in_category() function, like this: <?php if ( in_category( 4 ) ) : ?> <div class="event-post-icons"> <ul> <li class="single-post-date"><?php the_field('event_date'); ?></li> <li class="single-post-time"><?php the_field('event_time'); ?></li> <li ...


0

I have managed to fix it at my own. I have used following code to update post meta update_post_meta($post_id, 'tb_data', base64_encode(serialize($new_value_array))); ...and following code to get post meta $tb_meta = get_post_meta($post->ID, 'tb_data', true); $tb_meta_unserialized = unserialize(base64_decode($tb_meta)); I hope this will help ...


0

@qwerty, I was having a similar issue and I was able to use http://codex.wordpress.org/Function_Reference/wpautop Some more info on this thread: get_post_custom stripping styling issue


2

If the line breaks exist in the database, you just need to run your custom field output through wpautop(). Changes double line-breaks in the text into HTML paragraphs (<p>...</p>). If that doesn't work, then the line breaks probably are getting stripped before going into the database. In that case you'll need to share the code that saves ...


1

You have a couple of flaws in your code get_post_meta( 'fap_referral_link' ) should be get_post_meta( $post->ID, 'fap_referral_link', true ). Please see get_post_meta() You should always first check if you actually have posts before you run your foreach loop Never ever use extract(). It uses eval() which stand for EVIL. This has been completely removed ...


0

If two fields are named people[name], only the last value will be sent with the form. To be completely reliable, you'll need to use an id for each person you're collecting details on: <input name="people[0][name]"> <input name="people[0][email]"> <input name="people[1][name]"> <input name="people[1][email]"> ... Use an incrementing ...


0

Okay got the issue, here is the complete code that is saving data. The issues are explained at the bottom: /** * Adds a box to the main column on the Post and Page edit screens. */ function nss_mood_add_meta_box() { //$id, $title, $callback, $post_type, $context,$priority, $callback_args add_meta_box('nss_mood_id','Set your ...


0

Finally i got the answer i was wrong because i tried to send the variable you can not send the variable you have to just put the name of custom field slug. In the bellow snippet i have replaced $field with my custom field name slug _some_field like:- $keys['How did you learn about us?'] = '_some_field'; /** * Add the field to order emails **/ ...


0

Why not changing the loop? Inside the loop, just check to see if the custom-field or post-meta which you provided for the custom date is filled or not and show the post date or custom date according to the conditions. You can also have a special page for that category's timeline and a function for that specific page to make timeline using custom dates.


0

You need a loop within a loop - loop through a counter, and for each value, check for the existence of each key with the current counter value appended. // max custom field index $number = 40; // the counter $counter = ''; // the meta keys to check for $keys = array( 'custom_text', 'custom_image', 'custom_video' ); // all our custom field values ...


0

Use make_clickable() function: add_action( 'genesis_entry_footer', 'custom_comments_field' ); function custom_comments_field() { if ( is_single() && genesis_get_custom_field('Comments link text') ) : echo '<div class="comments-link">'. make_clickable( genesis_get_custom_field('Comments link text') ) .'</div>'; endif; } ...


2

Here's what I do to add an upload field to my taxonomy terms, in this example I add it to the built in Posts Categories but you could modify it to add in any taxonomy. Step One - Make sure we're using a enctype on our form: function edit_form_tag( ) { echo ' enctype="multipart/form-data"'; } add_action( 'category_term_edit_form_tag' , 'edit_form_tag' ...


0

You're just echoing the values. If you're wanting to actually create an array with the data in it I think you'll need something more like this. $args = array( 'post_type' => 'locations', 'posts_per_page' => 10 ); $loop = new WP_Query( $args ); $addresses = array(); while ( $loop->have_posts() ) : $loop->the_post(); $zipcode = ...



Top 50 recent answers are included