Ordering posts by publish date not working?

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

How to add a sortable date column in an admin page?

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

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

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)