How to disable monthly archive
Check this post by BetterWP. You may need to edit the code as it does not mention about monthly archives.
Check this post by BetterWP. You may need to edit the code as it does not mention about monthly archives.
You’ll want to filter the main query via pre_get_posts callback. If you’ll only want to handle one specific post in this manner, you can reference/exclude its post ID directly. If, however, you want this same behavior for any future private posts, then I would query all posts with $post->post_status of private, and exclude them. One … Read more
this function will check if you’re on a category page and 302 redirect to the latest post in that category. put it in your theme’s functions.php file. function my_check_if_cat(){ if ( is_category() ) : $category = get_the_category(); $latest = query_posts(‘showposts=1&cat=”.$category[0]->cat_ID); if(have_posts()) : wp_redirect(get_permalink($post->ID), 302); endif; endif; } add_action(“template_redirect’,’my_check_if_cat’);
The get_posts method of WP_Query is what does the heavy lifting as far as getting the posts to display. Before it does anything, however, there’s a hook called pre_get_posts that you can hook into. The hooked function will receive a reference (pointer) to the current query object. So you can change the query vars to … Read more
I would filter template_redirect, with an is_author() conditional, e.g.: function theme_slug_redirect_author_archive() { if ( is_author() ) { // Put your redirect code here; // Redirect to home_url(), or // return a 404, or whatever } } add_action( ‘template_redirect’, ‘theme_slug_redirect_author_archive’ );
You should take a look at content.php and do a check for is_post_type_archive() on whatever you want to hide. For example to hide the entry-meta section, you can do the following: <?php if ( !is_post_type_archive() ) { ?> <div class=”entry-meta”> <?php if ( ‘post’ == get_post_type() ) twentyfourteen_posted_on(); if ( ! post_password_required() && ( comments_open() … Read more
is_archive() doesn’t accept any parameter and return true for every archive page: Categories, tag, date, author, …. I think what you need is to check if you are in a category page (in a archive of the category taxonomy) or in the blog home: if ( is_category() || is_home() ) { wp_register_script(‘isotope’, get_template_directory_uri() . ‘/js/jquery.isotope.min.js’, … Read more
Update: Tried and works ok only without the WP no category base plugin, this is, you have to cope with the category though you can change it freely in Permalink settings. For a full URL in single posts, set the category structure in Settings > Permalinks, then in Category Base enter /%category%/%postname%/ (image below). The … Read more
There are two kinds of loops in PHP: With a unknown amount of elements ( while(), foreach(), do() while, etc) With a specific number of elements (for() ) You need a loop with a specific number of elements (in this case 12 elements). So a while loop is not what you need. At first take … Read more
thanks to @TheDeadMedic, I found the solution. I used reserved terms, and that’s why WordPress interpreted my inputs as query parameters. so for example with my categorys, I had to change my classes in my form : ‘post_category’ => array($_POST[‘cat’]), // Usable for custom taxonomies too by ‘post_category’ => array($_POST[‘my_cat’]), // Usable for custom taxonomies … Read more