404 error after publishing a post

I just ran into something similar to this. It had to do with refreshing permalinks. If you go to Settings -> Permalink and just click save see if it fixes your problem. It did for me. In the end I added the following to my functions.php file which updated the permalinks for me. I was … Read more

Exclude category on blog list page

From a plugin or your theme’s functions.php file: function wpse106861_mod_query( $query ) { /* are we on the blog page ? */ if ( $query->is_home() && $query->is_main_query() ) { /* get ID of news category */ $news_id = get_cat_ID( ‘news’ ); /* exclude posts in new from query */ $query->set( ‘category__not_in’ => array( $news_id ) … Read more

Add custom field to all posts in specific category

You can use WordPress functions to do this and just run it once, a fast example would be. function wpse_85236_add_photo_field(){ global $post; $photoquery = new WP_Query(‘posts_per_page=-1’); while ( $photoquery->have_posts() ) : $photoquery->the_post(); if ( in_category( ‘photography’ )) { add_post_meta($post->ID, ‘category’, ‘photography’, true); } endwhile; } add_action( ‘init’, ‘wpse_85236_add_photo_field’ ); Remember to remove the function after … Read more

Must permalinks always point to single post pages?

There are two hooks named ‘pre_post_link’ and ‘post_link’. Their first argument – which you can change – is the permalink. So … add_filter( ‘pre_post_link’, ‘wpse_42406_change_permalink’, 10, 2 ); function wpse_42406_change_permalink( $permalink, $post ) { // change the permalink, let it point to an archive etc. return $permalink; } … will change the output. In your … Read more

Keep a fluid max number of posts on site

Here is an idea but before we go into details, here are VERY VERY IMPORTANT notes NOTE: READ THIS FIRST Take a database back up before running this code. It is advisable to run this on a local install first for testing purposes. Note on wp_trash_post(), from the codex If trash is disabled, the post … Read more

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