Archive by Year

The Simple Yearly Archive Plugin does just that. This code will also do the trick: <?php // get years that have posts $years = $wpdb->get_results( “SELECT YEAR(post_date) AS year FROM wp_posts WHERE post_type=”post” AND post_status=”publish” GROUP BY year DESC” ); foreach ( $years as $year ) { // get posts for each year $posts_this_year = … Read more

Category archive in menu

WordPress has actions and filter to be used to add elements on menu admin, and so it’s possible to write a plugin that put on the menu admin screen the month/year archives. However, that plugin should consist in some dozen lines of code, and once you have not tried to write anyhing, if this was … Read more

paging is not working properly on news archives page [duplicate]

Using your custom get_posts() you are ignoring the $paged var. In this way, you’ll see always posts from the first page. According the Codex Page if you would like to alter the main query before it is executed, you can hook into it using pre_get_posts. function my_post_queries( $query ) { if (!is_admin() && $query->is_main_query()){ $query->set(‘posts_per_page’, … Read more

How to set a link to custom archieve page

I am working on my blog where I wish to have a archieve for only specific category post. If I understand you, you are doing this wrong. What you want to do is use pre_get_posts to restrict your archives to the one category. Something like this: function restrict_archives_to_cat($qry) { if ($qry->is_main_query() && $qry->is_date()) { $qry->set(‘cat’,5); … Read more

Show recent posts in single-post page

The function get_posts() accepts a parameter ‘post__not_in’, which allows you to specify an array of post IDs to exclude from the query. get_posts() is just a wrapper for WP_Query, so the documentation for this parameter can be found here. When inside the loop (such as inside single-events.php) you can retrieve the current post’s ID with … Read more

How to hide the year in archive link

You could use a regexp to remove the year, though it’s a little hacky: $string = wp_get_archives(‘type=monthly&limit=20&echo=0’); $pattern = ‘ ((19|20)\d{2}(</a>))’; echo preg_replace($pattern, ‘\\3’, $string); Answer from this stackoverflow question: https://stackoverflow.com/questions/5759720/have-wp-get-archives-return-a-string-with-no-year-in-it

date.php shows only three posts’ title. how to fix it?

Use the pre_get_posts action to modify number of posts per page on date archives. This would go in your theme’s functions.php file: function wpa_date_posts_per_page( $query ) { if ( !is_admin() && $query->is_date() && $query->is_main_query() ) { $query->set( ‘posts_per_page’, -1 ); } } add_action( ‘pre_get_posts’, ‘wpa_date_posts_per_page’ );

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