How to hide a post from 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

if there is only one post in the category, directly open

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’);

Preview Post/Custom Post types in Archive

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

Remove author archive

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’ );

Show only post titles in archives?

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

condition for only if is archive for default post type

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

front end publishing not working on front-end page

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

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