custom field functionality

Ok so i am not sure if i am able to get your question properly — so i am trying to list down what i understand. 1: You can create a custom post type (for testimonials) where your client/admin can fill out title/description/author name. 2: To be able to display them on specific pages – … Read more

WP_Query and two custom fields returns no posts

The first query gives the expected results when the date format was corrected. $query = new WP_Query(array( ‘post_type’=>’games’, ‘orderby’=>’menu_order’, ‘order’=>’asc’, ‘posts_per_page’ => 1, ‘meta_query’=> array( ‘relation’=>’AND’, array( ‘key’=>’game_date_time’, ‘value’=>$nowtoday, ‘compare’ =>’>’ ), array( ‘key’=>’home_team’, ‘value’=>’Allen’, ‘compare’=>’LIKE’ ) ) ));

Custom field totals

Get all of the post ids from the specific post type, loop through them and simply add the custom fields together and display the sum below the post type title on edit.php (Notice the add_filter first parameter, you need to change the products part to your post type name) add_filter(‘views_edit-products’,’products_price_sum’); function products_price_sum($views) { $args = … Read more

Custom field in external Javascript

I had a similar problem using custom field values in a widget that used JavaScript. I wrote a tutorial explaining it. Try this code: <?php global $post; $cf = get_post_meta($post->ID, ‘my_custom_field’, true); ?> <button onclick=”window.open(<?php echo json_encode($cf); ?>);”>Click me</button>

How to display data from custom fields in my custom shortcode?

You simply need to query your custom fields and return them with your shortcode: // EXAMPLE USAGE: // [loop the_query=”showposts=100&post_type=page&post_parent=453″] function custom_query_shortcode($atts) { // Defaults extract(shortcode_atts(array( “the_query” => ” ), $atts)); // de-funkify query $the_query = preg_replace(‘~&#x0*([0-9a-f]+);~ei’, ‘chr(hexdec(“\\1″))’, $the_query); $the_query = preg_replace(‘~&#0*([0-9]+);~e’, ‘chr(\\1)’, $the_query); // query is made query_posts($the_query); // Reset and setup variables $output=””; … Read more

Setting a custom $query->query_vars[‘meta_key’] breaks the WordPress menu

I was having the exact same problem on an archive page of a custom post type with a needless extra query; for pagination reasons. Searching for the same solution I found this post on Stack Overflow https://stackoverflow.com/questions/21303743/new-wp-query-or-pre-get-posts-to-view-all-posts-for-custom-post-type I had a play and added this line of code into the function. if( ! $query->is_post_type_archive()) return; So … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)