How to display lastest post date in the homepage?

I would save an option on post save: add_action( ‘save_post’, function($id,$p) { if ( (defined(‘DOING_AUTOSAVE’) && DOING_AUTOSAVE) || (defined(‘DOING_AJAX’) && DOING_AJAX) || ($p->post_status === ‘auto-draft’) ) { return; } update_option(‘_last_site_update’,$p->post_date); }, 1,2 ); And retrieve it with a variant of the function provided by @G-M : function my_last_updated( $format=”” ) { $last = get_option(‘_last_site_update’); if … Read more

How do I sort multiples pages?

Use sessions: <?php session_start(); if( isset( $_POST[‘order’] ){ $order = filter_input( INPUT_POST, ‘order’, FILTER_SANITIZE_STRING ); if( $order ) $_SESSION[‘order’] = $order; } if( isset( $_SESSION[‘order’] ) $order = $_SESSION[‘order’];

Duplicate posts

You can use a static class property to store a rolling list of posts that are used in previous queries. This method allows you to pass data between classes (widgets, modules, plugins, etc…), but will also work for a procedural workflow. Everything on the page that uses your intermediary class will know what posts to … Read more

Filter all queries with a specific taxonomy

Below code is an example that does what you want. See tax_query for more information. function my_get_posts( $query ) { // we only need to modify the query for logged in users if ( !is_user_logged_in() ) return $query; $current_user = wp_get_current_user(); // assuming that user’s region is stored as user_region meta key $user_region = get_user_meta( … Read more

How to get my loop to pull posts into three columns

First of all, never use query_posts Note: This function isn’t meant to be used by plugins or themes. As explained later, there are better, more performant options to alter the main query. query_posts() is overly simplistic and problematic way to modify main query of a page by replacing it with new instance of the query. … Read more

Order posts by tags count?

As @Robert hue says you can’t do it directly, you need a filter and a CASE in the orderby eg $args1 = array ( ‘orderby’ => ‘tag_count’, ‘order’ => ‘DESC’, ‘post_type’ => ‘post’, ‘pagination’ => true, ‘posts_per_page’ => ‘1’, // 1 post per page?! ‘meta_key’ => ‘_thumbnail_id’, ‘suppress_filters’ => false, ); function wpse173949_posts_clauses( $pieces, $query … Read more

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