Sort posts by most recently modified

If you use WP_Query you can set the orderby to modified and then the order to DESC and you’ll be good to go. If it’s not a custom query, you can just use the set() method on the default $wp_query global to do the same. Since get_posts() is just a wrapper for WP_Query, you can … Read more

Get posts inside Get terms problem

When you do the following in your code $posttags = get_the_tags($item->term_id);, $item is referring to a post object, not a term object. Therefore, term_id is an invalid property. This should be throwing a PHP notice. While not certain, I think what you are intending to do is: $posttags = get_the_tags($item->ID); since get_the_tags takes a post … Read more

How do I pass a post ID to the page URL?

First of all. The question is a little misleading. What you actually want is “post id(s) for current user”. Here we go: // Global variable for current user ID // More information: http://codex.wordpress.org/Function_Reference/get_currentuserinfo $user_ID; // You need to create a new WP query object // More info: http://codex.wordpress.org/Class_Reference/WP_Query $my_query = new WP_Query( array( ‘post_type’ => … Read more

Logged in user ID as post ID

You can get information on the currently logged in user using the get_currentuserinfo() function. For example: <?php global $current_user; get_currentuserinfo(); $username = $current_user->user_login; $user_id = $current_user->ID; ?> You can then use $username or $user_id in your custom loop. <?php // assign the variable as current category $category = $user_id; // concatenate the query $args=”cat=” . … Read more

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