Reverse chronology of post listing

You can add code below to the beginning of loop.php add_action(‘pre_get_posts’, ‘wpse_change_post_order’); function wpse_change_post_order($query){ $query->set(‘order’,’ASC’); $query->set(‘orderby’,’date’); } the oldest posts will be in the home page.

Post date vs. event date in WordPress

I’m not sure about a plugin, but you can definitely add custom meta that allows you to set the event date, or even an event daterange (my preferred way of handling this is an event date and a duration, cuts down on calculations in the backend and is generally easier to understand, but ymmv). This … Read more

Query posts from current year

You just need get current date and add it on data_query in wp_query, Look this: <?php $getdate = getdate(); $args = array( ‘date_query’ => array( array( ‘year’ => $getdate[“year”] ), ), ); $query = new WP_Query( $args ); ?> and then use loop: <?php if ( $query->have_posts() ): while ( $query->have_posts() ) : $query->the_post(); the_title(); … Read more

order users with drag’n’drop?

Quite a specific feature, never seen any plugin. But it’s a matter of taking a drag’n’drop plugin and adapting it. Here, a stripped and adapted version of My Link Order. Description and to-do: A new submenu is created in Users, My Users Order. In the plugin page, execute the function orderUsers() in your browser console, … Read more

Show child pages by menu order using Superfish Dropdown menu?

I downloaded this plugin and took a look and it does work as advertised for me. The function it uses for displaying the page list is: wp_list_pages(array( ‘sort_column’=>’menu_order’, ‘depth’=>’4’, ‘title_li’=>”, ‘exclude’=>$exclude )); ?> Which is very straightforward and does very explicitly order the items via menu_order. However, because it’s a core function subject to actions … Read more

Order by first name

Here is my solution function split_names( $name ) { $names = explode( ” “, trim( join( ” “, $name ) ) ); $first_name = array_shift( $names ); $last_name = array_pop( $names ); $middle_name = join( ” “, $names ); return array( “first_name” => $first_name, “middle_name” => $middle_name, “last_name” => $last_name ); } function sort_by_full_name( $arr1, … Read more

Query posts ordering by title, but ignore ” and special characters

Try this… $posts = get_posts( array( “orderby”=> “slug”, “order” => “ASC”, “post_type” => “my-custom-post-type”, “posts_per_page” => -1, “fields” => “ids”, “meta_query” => array( array( “key” => “ams_park_id”, “value” => get_the_ID(), ) ) ) ); Noticed I changed “orderby”=> “title”, to “orderby”=> “slug”. Typically the slug will be close to the title but all of the … Read more

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