How do display most popular post from a year earlier to the day?
How do display most popular post from a year earlier to the day?
How do display most popular post from a year earlier to the day?
If the given code is correct it might be the missing brackets on your pre_get_posts conditional. Let’s format it with proper indentation and spacing: function alter_query( $query ) { if( $query->is_main_query() && is_home() ) $query->set( ‘cat’, ‘2’ ); $query->set( ‘orderby’, ‘rand’ ); } add_action( ‘pre_get_posts’,’alter_query’ ); Because there’s no brackets for your conditional statement, it … Read more
Events are all showing the current date
Just for people passing by, for putting together all this code was not trivial. The problem was actually the lack of data. I solved adding data as metakey (added in my case when the order changes status) and echoing it as the column value. So the full code is: // Adding a new column to … Read more
Mini app that shows one unique quote each day. 56 rotating posts rotating for each themed weekday. It works, but I need your advice
I’m wondering if I can use any of the functions listed in the @wordpress/date package to convert a GMT date to a date in the user’s locale. Yes, you can use the dateI18n() function. However, the source date (i.e. the 2nd parameter for the above function) by default uses the time zone of the user’s … Read more
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
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
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
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