Single.php Active Category Class

As vancoder notes, a post can have multiple categories and the following code highlights each category, as well as the current month for the post. Add to your theme’s functions.php. // Generate active class for categories when viewing single posts // Props to Sam Nabi http://samnabi.com/blog/highlight-the-current-category-for-single-posts-in-wordpress function singlePostActiveCat ($CatText) { global $post; if (is_singular()) { … Read more

How to show specific year archive into dropdown list

<?php function foo($where) { return $where . ‘ AND YEAR(post_date) = 2010 ‘; } add_filter(‘getarchives_where’, ‘foo’, 1, 10); ?> <select name=”archive-dropdown” onChange=”document.location.href=this.options[this.selectedIndex].value;”> <option value=””><?php esc_attr_e( __(‘Select Issue’) ); ?></option> <?php wp_get_archives(‘type=daily&format=option’); ?> </select> <?php remove_filter(‘getarchives_where’, ‘foo’, 1, 10); ?>

Change plugin’s has_archive = true to false?

The register_post_type_args filter (available from WordPress v4.4 on) will allow post type registration arguments to be changed: function wpse206329_custom_post_type_args( $args, $post_type ) { if ( $post_type === “my_post_type” ) { $args[‘rewrite’] = false; } return $args; } add_filter( ‘register_post_type_args’, ‘wpse206329_custom_post_type_args’, 20, 2 );

Rewrite url / permalink for default archive – yearly / monthly

You can do this without adding rewrite rules by changing the $date_structure of the $wp_rewrite instance of the WP_Rewrite class: function wpa116030_init(){ global $wp_rewrite; $wp_rewrite->date_structure=”about/blog/archive/%year%/%monthnum%/%day%”; } add_action( ‘init’, ‘wpa116030_init’ ); Visit your Permalinks settings page after adding this code to flush the rewrite rules.

Include Custom Posts Type in Year/Month/Date Archive

Your code simply adds post types to the query when on the author archive so to do the same with date archive simply replace is_author to is_date : function custom_post_date_archive($query) { if ($query->is_date) $query->set( ‘post_type’, array(‘wp_plugin_review’, ‘png_gallery’, ‘post’, ‘news’) ); remove_action( ‘pre_get_posts’, ‘custom_post_author_archive’ ); } add_action(‘pre_get_posts’, ‘custom_post_date_archive’);

Create a month by month archive of pages (not posts)

You could probably hack something together, but you should probably understand that, in WordPress, a basic assumption (and operating principle) is that static Pages are not chronological. IMHO, a better approach would be to store the content as Blog Posts, and then to use Categories (or perhaps, a custom taxonomy) to identify that content, and … Read more

Custom taxonomy archive page not working

Your permalink as given is domain.com/curriculum-area/equality but you registered your taxonomy as Curriculum Area. For domain.com/curriculum-area/equality to work, change Curriculum Area in: register_taxonomy( ‘Curriculum Area’, ‘course’, $args_curriculum_area_taxonomy ); to be: register_taxonomy( ‘curriculum-area’, ‘course’, $args_curriculum_area_taxonomy ); Also change this line ‘taxonomies’ => array( ‘curriculum_area’ ), to ‘taxonomies’ => array( ‘curriculum-area’ ), I forgot to say, remember … Read more

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