Add new post using a page inside the website

You have never read the WP documentation? Create any template and form and when submitting the form it could be Example: $args = array(‘post_type’=>’post’, ‘post_title’=>’your title’, ‘post_status’=>’publish’, ‘post_content’=>’post content’); wp_insert_post ($args); This will allow any post page or custom post type to insert the post

WP_Query with Pagination and orderby meta_value_num showing duplicates

$paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1; $args = array( ‘tag’ => $taxonomy, ‘post_type’ => ‘initiative’, ‘paged’ => $paged, ‘posts_per_page’ => 9, ‘category_name’ => $category, ‘tag__not_in’ => array(15), ‘meta_key’ => ‘initative_weight’, ‘orderby’ => array(‘meta_value_num’ => ‘DESC’, ‘title’ => ‘ASC’), ‘post_status’ => ‘publish’ ); I changed tag__not_in to an array and updated the orderby to be … Read more

Get file size from ACF repeater field

As far as I know, WordPress has nothing built in for this, I would just do. Same thing did you also. So make sure that the $attachment_id having value. You can use custom function by place that function code in your function.php file. function getSize($file){ $bytes = filesize($file); $s = array(‘b’, ‘Kb’, ‘Mb’, ‘Gb’); $e … Read more

Custom Fields as Post Type Options

Your code… function wpuf_update_vehicle_year( $post_id ) { $year = get_post_meta( $post_id, ‘seek_property_year’, true ); update_post_meta( $post_id, ‘seek_property_year’, $year ); } add_action( ‘wpuf_add_post_after_insert’, ‘wpuf_update_vehicle_year’ ); is probably executed, but nothing will change anyway because the thing it does is to grab meta data (with get_post_meta) for seek_property_year and then update the same meta data with the … Read more

Sorting posts by meta values: 2 different orders

I think it should be able to hook into the posts_clauses filter to add a field to your sql query. add_filter( ‘posts_clauses’, ‘intercept_query_clauses’, 20, 1 ); function intercept_query_clauses( $pieces ){ global $wpdb; $pieces[‘fields’].=’, (IF(UNIX_TIMESTAMP()>=’.$wpdb->postmeta.’.meta_value,’.$wpdb->postmeta.’.meta_value,(UNIX-TIMESTAMP() – ‘.$wpdb->postmeta.’.meta_value)+UNIX_TIMESTAMP(‘2099-01-01′))) as timestamp_direction’; $pieces[‘orderby’]=’timestamp_direction ASC’; return $pieces; } The logic is as follows: Let’s say you have some timestamps in … Read more