Trying to save custom post type from frontend partially working
Have you tried TDO Mini Forms? It allows users posting content from the frontend. I don’t know if it allows submitting custom types, but at least can give you a hint.
Have you tried TDO Mini Forms? It allows users posting content from the frontend. I don’t know if it allows submitting custom types, but at least can give you a hint.
convert Custom Fields Option-Values to Tags/Taxonomy
You are abusing pre_get_posts badly with that code. With pre_get_posts the point is to alter the main query. By doing that you reduce the number of necessary queries and save some processing time, plus keep the WordPress globals— $wp_query, for example– neat for any other code that might need them. What you are doing is … Read more
You don’t have a ON for your LEFT JOIN, I guess the WHERE statement you use has to be the ON statement. You should use this query instead: $querystr = ” DELETE FROM $wpdb->posts LEFT JOIN $wpdb->postmeta ON $wpdb->postmeta.post_id = $wpdb->posts.ID WHERE $wpdb->postmeta.meta_key = ‘randomID’ AND $wpdb->postmeta.meta_value=”$randomID””; Reference here: http://dev.mysql.com/doc/refman/5.0/en/join.html
I’m sure this not best answer, however you may try like this add_action(‘save_post’, ‘add_my_taxonomy’); function add_my_taxonomy($post_ID) { $area = array( ‘ny’ => ‘New York’, ‘la’ => ‘Los Angeles’ ); $zip = array( ‘ny’ => ‘10001, 10002, 10003, 10004, 10005, 10006, 10007, 10008, 10009, 10010, 10011, 10012, 10013, 10014, 10015, 10016, 10017, 10018, 10019, 10020, 10021, … Read more
I think you forgot to check if $the_query have posts. <?php $args = array( ‘post_type’ => ‘testimonials’, ‘posts_per_page’ => 1, ‘orderby’ => ‘rand’ ); $the_query = new WP_Query( $args ); ?> <?php if ( $the_query->have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); ?> <div class=”testimonial push_2 grid_10 clearfix”> <blockquote>“<?php the_field( ‘testimonial’ ); ?>”</blockquote> <cite>—<?php … Read more
Yes! Yes you can! You can use this code to retrieve a stored option: $value = get_post_meta($post->ID,’customfieldname’,true); // where true means only return 1 custom field by this name You can use this code to save a stored option: update_post_meta($post->ID,’customfieldname’,$valuetobestored); The above code will need to be inside the post loop, though you can supply … Read more
To get the posts from a post type you can use get_posts() $posts = get_posts( array ( ‘numberposts’ => -1, ‘posts_per_page’ => -1, ‘post_type’ => ‘store’ ) ); Be aware, the -1 is dangerous: If there are millions of stores, the query might run into a time-out. Here is a very basic example for such … Read more
Using save post action I check state: <?php add_action(‘save_post’ ,’my_save_postdata’); function my_save_postdata ( $post_id ) { if ( defined(‘DOING_AUTOSAVE’) && DOING_AUTOSAVE ) { return $post_id; } // logic }
First, content_save_pre is a very old hook. Adam Brown has a warning that: This hook does not occur in the most recent version of WordPress (3.5). Do not use it. It is deprecated. You should look at the list of “related hooks” below to see if you can figure out what replaced it. I would … Read more