Sort Posts By Custom Field Date?
Use meta_value instead of meta_value_num <?php $course = new wp_query( array ( ‘posts_per_page’ => ’10’ , ‘post_type’ => ‘course’, ‘orderby’ => ‘meta_value’, ‘meta_key’ => ‘course_date’, ‘order’ => ‘DESC’ ) ); ?>
Use meta_value instead of meta_value_num <?php $course = new wp_query( array ( ‘posts_per_page’ => ’10’ , ‘post_type’ => ‘course’, ‘orderby’ => ‘meta_value’, ‘meta_key’ => ‘course_date’, ‘order’ => ‘DESC’ ) ); ?>
You are right the wp_postmeta table: does not save any kind of time stamp. Unlike for example the wp_posts table with post_date, post_modified and such. So you have to implement a mechanism to keep track of the points in time when votes happened yourself.
Add categories to your custom posts. Ex: add_action( ‘init’, ‘create_gallery_taxonomies’, 0 ); function create_gallery_taxonomies() { $labels = array( ‘name’ => _x( ‘B&A Categories’, ‘taxonomy general name’ ), ‘singular_name’ => _x( ‘B&A’, ‘taxonomy singular name’ ), ‘search_items’ => __( ‘Search B&A Categories’ ), ‘all_items’ => __( ‘All B&A Categories’ ), ‘parent_item’ => __( ‘Parent B&A Category’ … Read more
Probably but this would be using a PHP function along the lines of, $metadate = rwmb_meta( ‘ns_event_date’ ); $date = new DateTime($metadate); echo $date->format(‘d-M-Y’);
EDIT 2 – FINAL EDIT Just before I start with this edit, just a few things here The code in my answer are the basics and meant to demonstrate the concepts. I have now tested both sets of code, and all works as expected. You have to add all your desired mark-up, styling and template … Read more
Your argument for is_singular() is wrong It should be an array is_singular(array(‘post’,’movie’)) You can read more about the argument passed from this link here
The best practice in the WordPress world is to “escape late” i.e. at the point of output. While the two examples are effectively the same, the first one would be more effective if that code is ever refactored and the value of $portf_icon changes between where it’s first assigned & where it’s output.
Meta data keys do not have to be unique, you can have multiple rows of the same key, each containing singular values. If you use get_post_meta to fetch a key and don’t set the 3rd argument to true, the function gets all the individual values and returns them as an array, which is not the … Read more
If you just want to check if a meta value exists before outputting markup, then if( get_post_meta( $post->ID, ‘_cmb_linkCheckbox’, true ) ){ ?> <section id=”footerLinks”> <?php // your markup… ?> </section> <?php } or if the value is “on”: if( ‘on’ == get_post_meta( $post->ID, ‘_cmb_linkCheckbox’, true ) ){ // etc.. }
You can use count_user_posts() function to get the number of total posts for specific author. With looping through all posts by the specific author, you can get the number of likes on each post and store it/add it in one variable. Here is a function for that. <?php function avg_num_of_likes() { $author = get_user_by( ‘id’, … Read more