If modified on same day, show only time

Give this a try: if(get_the_modified_date(‘zY’)==date(‘zY’)) { the_modified_date(‘g:i a’); } else { the_modified_date(‘F j, Y’); echo ‘ at ‘; the_modified_date(‘g:i a’); } It checks that the modified date is the current day. If it is, it only displays the modified time. Otherwise it displays both the date and time.

Get posts of ONE taxonomy term of custom post type

You can try making the $args array more specific with: $args = array( ‘post_type’ => ‘portfolio’, ‘tax_query’ => array( array( ‘taxonomy’ => ‘locations’, ‘field’ => ‘slug’, ‘terms’ => ‘paris’ ) ) ); Grabbed this snippet similar to one on the WP Query page in the codex. Also, this is assuming that your custom post type … Read more

Get mixed category random posts

I whipped this up: echo ‘<ul>’; the_random_posts(); echo ‘</ul>’; /** * Send random posts to the browser (STDOUT). */ function the_random_posts() { // Use your own category ids. $random_posts = array_merge( get_random_posts( 31, 3 ), get_random_posts( 11, 1 ), get_random_posts( 24, 1 ) ); foreach ( $random_posts as $post ) { // Change this line … Read more

Ajax load more button in Recent posts widget

Look at WordPress’s documentation on AJAX In your theme or plugin, you’ll want to have code like: add_action(‘wp_ajax_my_load_recent’, ‘my_load_recent_posts’); add_action(‘wp_ajax_nopriv_my_load_recent’, ‘my_load_recent_posts’); function my_load_recent_posts() { $args = array( /* Arguments go here, i.e. how many posts to get */ ); query_posts($args); /* [1] */ /* Header wrap output */ if (have_posts()) : while (have_posts()) : the_post(); … Read more

Turn on and off custom post type from admin?

Yes, custom post types are registered on the fly, on every request. So you can create an option, say active_custom_post_types and check for that before you register the post type. Pseudo-code: $possible_cpts = array( ‘book’, ‘portfolio’ ); $active_cpts = get_option( ‘active_custom_post_types’ ); if ( ! empty ( $active_cpts ) && is_array( $active_cpts ) ) { … Read more

Why is my Blog Page ID == First Post ID?

the ‘posts page’ ID when using a static front page and a different posts page is: get_option( ‘page_for_posts’ ) in some context: if( is_home() && get_option( ‘page_for_posts’ ) ) { $page_ID = get_option( ‘page_for_posts’ ); }