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

Displaying terms based on loop posts?

I think you can try the following options. wp_list_categories with the ‘show_count’ parameter http://codex.wordpress.org/Template_Tags/wp_list_categories get category and use $count = $category->category_count; http://codex.wordpress.org/Function_Reference/get_category You can traverse up the functions to get_term if those don’t work and see what is in there, even though you probably can use get the terms you will have to parse the … Read more

sticky post in custom loop

if you use ‘post__in’ => get_option(‘sticky_posts’) then you are only filtering on posts that are sticky. As mrwweb said you need to look at your query. Then think of the ‘loop’ you want. Do you want to show all posts in a specific query or all posts that are sticky in all categories? You might … Read more

Recent posts on a static home page

First, Welcome! I guess you use the file front-page.php for displaying your homepage. What you have to do, is add the following code into your front-page.php: <h2>Recent Posts</h2> <ul> <?php $args = array( ‘numberposts’ => ‘5’ ); $recent_posts = wp_get_recent_posts( $args ); foreach( $recent_posts as $recent ){ echo ‘<li><a href=”‘ . get_permalink($recent[“ID”]) . ‘” title=”Look … Read more

Get search.php results in header.php?

Now, is it possible to check if page is the search page is_search() AND what’s the search string is_search() AND print get_query_var( ‘s’ ) AND how many posts were found? is_search() AND print $GLOBALS[‘wp_query’]->number_posts() … or if you got a custom query… $my_query = new WP_Query( array( /* whatever args */ ) ); is_search() AND … Read more

Repeating Loop on my Posts Page

In order not to interfere with main wp_query I would recommend to use this hook, that I used on one of my websites. //wp_query to buffer $temp_query = clone $wp_query; //Use main wp_query with attributes $wp_query = new WP_Query( array( ‘posts_per_page’ => 10 ) ); if(have_posts()) : while(have_posts()) : the_post(); //your code with html and … Read more

Problems with loop

the_post() function is what advances the internal counter and loads the data for the next post. You’re calling it between the title and content: the_title(); the_post(); the_content(); You want to change the order and move it before the output of any of the other template tags: the_post(); the_title(); the_content();

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