Post timeline (pagination with date, not numbers)

Looks like you asked this question elsewhere, PROBLEM: WordPress Support Forum SOLUTION: PasteBin AUTHOR: Alan Jackson For reference: <?php echo ‘<ul id=”timeline”>’; echo ‘<li>Latest</li>’; $prev_month=””; $prev_year=””; $args = array( ‘posts_per_page’ => 10, ‘ignore_sticky_posts’ => 1 ); $postsbymonth = new WP_Query($args); while($postsbymonth->have_posts()) { $postsbymonth->the_post(); ?> <li><a href=”https://wordpress.stackexchange.com/questions/50592/<?php the_permalink(); ?>”><?php the_time(‘j’); ?></a></li> <?php if(get_the_time(‘F’) != $prev_month || … Read more

How to split text text text into array

Firstly, you need to remove the paragraph tags that were added by the wp_autop filter. There’s another answer that covers this pretty well: Is there an uw-wp_autop function? I’m going to change the function a little for our purposes (based on the markup example you gave): function reverse_wpautop( $s ) { // Strip newlines $s … Read more

Date calculations from 2 custom fields

I don’t know how much this will help, but when I’ve done date/time comparisons, I’ve always had to convert them to UNIX timestamps first (converts the date/time to a numeral, which you can compare as less than/greater than/equal to the next number), and then after the difference is sorted, convert it back with date(). A … Read more

Displaying Archives List

There is but the filter sucks, it only gives you the link HTML: add_filter( ‘get_archives_link’, ‘wpse74891_archives_link’ ); function wpse74891_archives_link( $link ) { $link = preg_replace_callback( ‘/>([A-Za-z]+\s+\d{4})/’, function( $matches ) { return ‘>’ . date( ‘m.y’, strtotime( $matches[1] ) ); }, $link ); return $link; } Using this method you can pass in any date format … Read more

After wp_insert_post(), date_i18n() and date() outputs are adjusted to GMT

If you do not pass a date to wp_insert_post(), get_gmt_from_date() is called. And look at that function’s content: function get_gmt_from_date($string, $format=”Y-m-d H:i:s”) { preg_match(‘#([0-9]{1,4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})#’, $string, $matches); if ( ! $matches ) return date( $format, 0 ); $tz = get_option(‘timezone_string’); if ( $tz ) { date_default_timezone_set( $tz ); $datetime = date_create( $string ); if ( … Read more

WP_Query most viewed posts, in multiple Post Types, last 30 days, excluding a specific taxonomy term

You can try: $the_query = new WP_Query( array( ‘posts_per_page’ => ‘5’, ‘v_sortby’ => ‘views’, ‘post_type’ => array( ‘post’, ‘music’, ‘videos’, ‘albums’ ), ‘tax_query’ => array( array( ‘taxonomy’ => ‘content’, ‘field’ => ‘slug’, ‘terms’ => array( ‘indy’ ), ‘operator’ => ‘NOT IN’ ) ) )); to exclude the indy term in the content taxonomy.

Changing the post date without causing 404 error

You’ll need to add 301 redirects for the old URL to the new one. Your best bet is to do this via .htaccess, in your theme, or using a plugin like one of these: http://wordpress.org/plugins/simple-301-redirects/ http://wordpress.org/plugins/safe-redirect-manager/ Edit: Another option OPtion 2 would be to disregard the date in the URI altogether. You could unset them … Read more

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.