Image upload and path to custom field

Found the solution. Forgot 2 lines of code. New is line 2 and line 11. I post the complete code: if( ‘POST’ == $_SERVER[‘REQUEST_METHOD’] && !empty( $_POST[‘action’] ) && $_POST[‘action’] == “new_post”) { $file=$_FILES; // Funktion zum Image-Upload, falls sie noch nicht existiert if ( ! function_exists( ‘wp_handle_upload’ )) { require_once(ABSPATH . “wp-admin” . ‘/includes/image.php’); … Read more

Run Function if Order Meta Exists – WooCommerce

WooCommerce orders are posts and behave the same as any WordPress post. So you can use the same WordPress functions to update or read the post meta data. <?php $meta_values = get_post_meta($post_id, $key, $single); ?> For your example I’d suggest: $match_order_meta = get_post_meta( $order->ID, ‘My_Checkbox’, TRUE); The ‘TRUE’ flag tells WordPress to return the value … Read more

Custom metabox not working

Problem #1: First problem: inside home-meta.php, pull all of your add_meta_box() calls outside of the add_meta_boxes_home() callback, and get rid of the callback and add_action() call. You handle this already, with the add_meta_boxes_page callback in functions.php, that includes home-meta.php. Problem #2: Warning: Invalid argument supplied for foreach() in /Users/[my_mac]/Sites/[site_dir]/wp-content/themes/[site_theme]/metaboxes/home-meta.php on line 224 Assuming that this … Read more

KEY and VALUE custom field issue

I don’t know if you can count on the order of both custom fields to be equal when returned from get_post_meta(), but if you can, you could use: $links = get_post_meta($post->ID, ‘links’, false); $URLs = get_post_meta($post->ID, ‘URLs’, false); for ( $i = 0; $i < count( $links ); $i++ ) { if ( empty( $URLs[$i] … Read more

Custom Theme Fields in Settings Menu – apply filters to one of those fields?

You can create a custom filter using filter functions of Plugin API. I have changed you code as following to create and use custom filter. function add_gcf_interface() { add_options_page(‘Other’, ‘Other’, ‘8’, ‘functions’, ‘otherGlobalOptions’); } function otherGlobalOptions() { ?> <div class=”wrap”> <h2>Sonstiges</h2> <form method=”post” action=”options.php”> <?php wp_nonce_field(‘update-options’) ?> <p><strong>Welcome Message</strong><br /> <textarea name=”welcomemessage” cols=”100%” rows=”7″><?php echo … Read more

Add Custom Fields After Page Title

Use get_post_meta() in the theme template you want to modify. Like so… <h1>If This Were Your Page Title</h1> <?php echo get_post_meta(get_the_ID(), ‘Your Custom Field Name’, true); ?> Easy peasy. 🙂

How to exclude custom fields from search queries?

If I understand you correctly, you need to have post metas in your query. This is where the meta_query parameter of the WP_Query class comes to help. The meta_query is an array of arrays. Example from the codex: $args = array( ‘post_type’ => ‘my_custom_post_type’, ‘meta_key’ => ‘age’, ‘orderby’ => ‘meta_value_num’, ‘order’ => ‘ASC’, ‘meta_query’ => … Read more