Including Database Generated Pages in Site Search [closed]
Including Database Generated Pages in Site Search [closed]
Including Database Generated Pages in Site Search [closed]
$songQuery = new WP_Query(‘meta_query’ => array( array( ‘key’ => ‘song-id’, ‘value’ => ‘song id value here’, ‘compare’ => ‘=’ ) )); You can use above code to query with custom field then use loop to get the contents.
For anyone who may have a similar need, I solved this the following way (on authors.php): First I get the author ID: $author = get_user_by( ‘slug’, get_query_var( ‘author_name’ ) ); // ID is accessed this way: $author_id = $author->ID; I then created a custom query: $query = ” SELECT p.* FROM $wpdb->postmeta m JOIN $wpdb->posts … Read more
$wp_query meta_key naming issue [closed]
We can improve a little bit with : function specific_enqueue($hook_suffix) { if( ‘post.php’ == $hook_suffix || ‘post-new.php’ == $hook_suffix ) { wp_enqueue_script( ‘custom_js’, get_template_directory_uri() . ‘/inc/meta/custom.js’, array( ‘jquery’ )); wp_enqueue_style( ‘custom_css’, get_template_directory_uri() . ‘/inc/meta/custom.css’) } } add_action( ‘admin_enqueue_scripts’, ‘specific_enqueue’ );
For posting images you should use the wordpress function media_handle_upload <?php if (isset($_FILES[‘text-two’])) require_once(ABSPATH . “wp-admin” . ‘/includes/image.php’); require_once(ABSPATH . “wp-admin” . ‘/includes/file.php’); require_once(ABSPATH . “wp-admin” . ‘/includes/media.php’); $attach_id = media_handle_upload( $_FILES[‘text-two’], $post_id ); update_post_meta($post_id,’textTwo’, $attach_id)); ?> Also check this function wp_handle_uploadhttp://codex.wordpress.org/Function_Reference/wp_handle_upload to handle uploads in wordpress
Add WYSIWYG to Image Description field
WP_Meta_Query causing long-running MySQL queries
As you will probably want to eventually do some reporting on the data, e.g. print a temperature average from this month last year in area X, I’d opt for custom tables from the beginning. I’m saying tables, because I don’t see a reason why you wouldn’t put the locations into a custom table as well. … Read more
You have to modify WooCommerce search query. Hook into this action: do_action( ‘woocommerce_product_query’, $query, $instance ); Detect if it is a search query Add your _subtitle meta Something like this (not tested): if ( $query->is_search ) { $query->set(‘meta_query’, array( array( ‘key’ => ‘_subtitle’, ‘value’ => $query->query_vars[‘s’], ‘compare’ => ‘LIKE’ ) )); };