weekly archive for custom category

I read the readme.txt file of Archives for a category WordPress plugin. The plugin author has stated following limitation on it. Limitations This plugin does not work for weekly archives. The list with archive links is correct, but the links themselves do not include the category. So when used, WordPress will not filter the resulting … Read more

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

What’s wrong with my date_query?

‘date_query’ argument takes an additional option that is ‘relation’ that can be AND or OR. If we consider the relation OR your code, that use exactly same date for ‘before’ and ‘after’ with ‘inclusive’ set to true, should return all your posts: posts before a date + posts after that date + posts in that … Read more

How can I get the query that would be run for the archive page?

In each of your hooks & filters handlers, in addition to checking for archive conditions, check for a custom query var that you can then set for a custom/manual query. For example, where you might have: function wpse_223991_pre_get_posts( $wp_query ) { if ( $wp_query->is_main_query() && $wp_query->is_post_type_archive( ‘my_post_type’ ) ) { // Awesome custom stuff } … Read more

Sorting posts by season

Probably the most “WordPress-y” approach to such a problem is to store the date of your ‘event’ custom post-type in the post’s metadata. Enabling users to set meta-data on a post is usually accomplished by using the ‘register_meta_box_cb’ argument to the register_post_type() function to add an extra “meta box” interface to the pages for creating … Read more

Insert static element only once in query archive

Use the Index of the post currently being displayed to trigger when your custom content is rendered. current_post can be found on WP_Query from within the loop. <?php while( $archive_query->have_posts() ) : $archive_query->the_post(); ?> <article <?php post_class(); ?>> The Content </article> <?php if ( $archive_query->current_post === 2 ): ?> <div>Custom Content</div> <?php endif; ?> <?php … Read more

Hierarchical Custom Post Types – Show only parent on tax archive?

Figured a simple pre_get_posts would do the trick, It will, you just need to query posts that have a parent of 0. Assuming your taxonomy slug/name is literally just region: function wpse_286405_parents_only( $query ) { if ( ! is_admin() && $query->is_tax( ‘region’ ) ) { $query->set( ‘post_parent’, 0 ); } } add_action( ‘pre_get_posts’, ‘wpse_286405_parents_only’ );

conditional for sub category on archive page

You are looking for the cat_is_ancestor_of() function. https://codex.wordpress.org/Function_Reference/cat_is_ancestor_of The example in the WP codex is very close to what you are attempting for your archive template. <?php // if the category is music or a music SUBcategory, if (cat_is_ancestor_of( 4, $cat ) or is_category( 4 ) ): ?> <div id=”music_subnav_menu” class=”subnav_menu”> <?php wp_nav_menu( array( ‘menu’ … Read more

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