How we display Archives for specific categories

Add this to your functions.php file and replace ‘Uncategorized with the category name add_filter( ‘getarchives_where’, ‘wse95776_archives_by_cat’, 10, 2 ); /** * Filter the posts by category slug * @param $where * @param $r * * @return string */ function wse95776_archives_by_cat( $where, $r ){ return “WHERE wp_posts.post_type=”post” AND wp_posts.post_status=”publish” AND wp_terms.slug = ‘Uncategorized’ AND wp_term_taxonomy.taxonomy = … Read more

Multiple filters for wp_get_archive

Make use of custom parameter, lets call it wpse__current_year, which will accept two values, true (includes current year) and false (excludes current year). Lets incorporate that function show_monthly_archive( $post_type ) { $current_year_args = array( ‘type’ => ‘monthly’, ‘limit’ => ’12’, ‘format’ => ‘html’, ‘before’ => ”, ‘after’ => ”, ‘show_post_count’ => false, ‘echo’ => 1, … Read more

How to replace a javascript select box onchange event to a form submit action?

It’s not working because: You are redirecting home You don’t listen for the $_GET variable so the archive link is just appended to your home url You need to add a function that listens for that $_GET variable. just add this to your functions.php file add_action( ‘template_redirect’, ‘wpse_archive_select’ ); function wpse_archive_select(){ if( isset( $_GET[ ‘archive-dropdown’ … Read more

Replace Archive Widget Link Text

You can use regular expression and the preg_replace_callback() function: function _make_khmer_link_replace_callback( array $matches ) { return ‘<a’ . $matches[1] . ‘>’ . convert_numbers_to_khmer( $matches[2] ) . ‘</a>’; } function make_khmer_link( $link ) { if ( get_bloginfo( ‘language’ ) == ‘km’ ) { $link = preg_replace_callback( ‘#<a(.*?)>(.+?)</a>#’, ‘_make_khmer_link_replace_callback’, $link ); } return $link; } add_filter(‘get_archives_link’, ‘make_khmer_link’); … Read more

How to limit wp_get_archives to show months for the X years only

If using “regular” query in theme file (sidebar.php for example), this code will help do the trick: <?php wp_get_archives(‘type=monthly&limit=12’); ?> The above (and below) will only show the last 12 months. However if using a widget, then add this code to your functions.php file: function my_limit_archives( $args ) { $args[‘limit’] = 12; return $args; } … Read more

How to have Multiple Archives Widgets, one archive widget per category (in a different page)?

I finally found an answer using WordPress rewrites. The whole code is at the end and can be pasted in functions.php. There is just one parameter that you have to change $rules = cpt_generate_date_archives(‘news’, $wp_rewrite); news is the name of the post_type. So I added a second line to show how to have two archives. … Read more

techhipbettruvabetnorabahisbahis forumueduedusedueduseduedusedueduseduedus