querying with custom meta field with meta_query

There’s actually a better solution that will (hopefully) be rolling out in WordPress 3.4 — you can run the patch as a hotfix now if you’d like, but here’s the TRAC link for the patch: http://core.trac.wordpress.org/ticket/18158 With this, you can do … $my_query = new WP_Query( array( ‘meta_query’ => array( array( ‘key’ => ‘foo’, ‘compare’ … Read more

Adding Custom Fields for Img in Posts

You should use the post thumbnail feature. Add support for this feature with this line in your functions.php file: add_theme_support( ‘post-thumbnails’ ); You can also set a new thumbnail size that will be cropped on new added photos to use this in your theme. Add this code to set a new thumbnail size (also in … Read more

get_pages sort alphabetically by meta value

The get_pages function is rather old and really shouldn’t be used anymore. Use a get_posts instead (a Page is just a special type of Post): $listingPages = get_posts( array( ‘meta_key’ => ‘streetAdd’, ‘post_type’ => ‘page’, ‘post_status’ => ‘publish’, ‘orderby’ => ‘meta_value’, ‘order’ => ‘ASC’, ) );

Filter results with custom field values and dropdown

Edited according to first comments and Pastebin code: <?php /* You can also leave ‘action’ blank: action=”” */ ?> <form method=”post” action=”<?php echo $_SERVER[‘PHP_SELF’]; ?>”> <select name=”my_size” id=”size” class=”postform” onchange=”submit();”> <option selected=”selected”>Choose a size</option> <option value=”10″>10</option> <option value=”20″>20</option> </select> </form> <?php /* Reset filter */ ?> <p><a href=”https://wordpress.stackexchange.com/questions/83928/<?php the_permalink(); ?>”>Clear filter</a></p> <?php if( !isset($_POST[‘my_size’]) || … Read more

Set post title from two meta fields

You are using wrong variable on the following line: $data[‘post_title’] = $post_title; you should use $event_title in $post_title as following: $data[‘post_title’] = $event_title; Also Get Post ID from $postarr parameter. Updated Code : function set_event_title( $data , $postarr ) { if($data[‘post_type’] == ‘events’) { $event_date = get_post_meta($postarr[‘ID’],’event_datetime’,true); $event_venue = get_post_meta($postarr[‘ID’], ‘venue_name’ , true); $event_title = … Read more

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