Cannot save CPT meta box

It’s your nonce generation and checking… You also weren’t saving your audio link and I cleaned the setting of the meta up (sanitize the URL and fix the conditionals) This works locally for me <?php add_action( ‘init’, ‘create_post_type’ ); function create_post_type() { register_post_type( ‘Sermon’, array( ‘labels’ => array( ‘name’ => __( ‘Sermons’ ), ‘slug’ => … Read more

how to display a widget only on a page where the custom field is defined?

If you have a custom field (metadata) attached to a particular post, page or custom post type, you can do something like the following in your page template file: Example example-template-file.php <?php $sidebar_id = ‘my-custom-sidebar-id’; $my_custom_meta_value = get_post_meta(get_the_ID(), ‘my_custom_meta_key’, true); if ( !empty($my_custom_meta_value) && is_active_sidebar($sidebar_id) ) { dynamic_sidebar($sidebar_id); } ?> Notes: dynamic_sidebar, is_active_sidebar

Adding auto-complete to custom gravity field not working

I have solved my problem using below code.So may be helpful for someone.I have tried by reference style for autocomplete <script> var locations=”<?php echo $json;?>”; var locations_array = JSON.parse(locations); locations_array.sort(); function monkeyPatchAutocomplete2() { jQuery(“#result”).remove(); // Don’t really need to save the old fn, // but I could chain if I wanted to var oldFn = … Read more

How to hide a custom field if there is not a value

I believe you might be looking for this: Types Conditional FIelds Display And set each field to display only if not empty. Then you can set up an array of field labels… $fields[‘goal’] = ‘My Goals: ‘; $fields[‘commitment’] = ‘My Commitments :’; // … and so on… Then loop through the fields to display them: … Read more

Pass current post title to a predefined link

Looks like it’s possible to use a placeholder tag, the following is the PHP code using a _custom_link value of http://somelink.com/?ref=%%title%%. <?php // must be within the Loop $ref_slug = strtoupper(sanitize_title_with_dashes(get_the_title())); $regex = ‘(\%\%title\%\%)’; $ref_link = ( get_option(‘_custom_link’) ) ? preg_replace( $regex, $ref_slug, get_option(‘_custom_link’)) : null; echo $ref_link; ?>