How to trigger 404 for custom query var?

There is an action specifically for this: function my_parse_query( $wp_query ) { if ( $wp_query->get( ‘my_custom_var’ ) > 42 ) { $wp_query->set_404(); status_header( 404 ); } } add_action( ‘parse_query’, ‘my_parse_query’ ); That should load the 404.php template in your theme, if you have it. Otherwise, it will fall back to index.php. This will also trigger … Read more

WordPress generating 404 on .mp4 file in theme folder

Using get_template_directory_uri() or get_stylesheet_directory_uri() you can retrieve the url to your themes folder, and after that you just need to specify the path starting from there. Your code should look like this: <source src=”https://wordpress.stackexchange.com/questions/256580/<?php echo get_template_directory_uri() .”/assets/videos/videobg.mp4′; ?>” type=”video/mp4″>

Feed 404 Errors

For all those who might hit the same problem, here is the solution: Disable in Yoast the “remove category” option in advanced section. Then install this plugin: https://wordpress.org/plugins/remove-category-url/ ( do use any other plugin as this one works – yes, I tried them all) For some reason the Yoast solution and all other plugins don’t … Read more

Uploaded image, but not showing

I think the problem is that you are storing your images in /srv/www/wp-uploads/blog.linformatronics.nl/2013/01 but your link to the image is https://blog.linformatronics.nl/wp-uploads/2013/01/ccs5licence1.png. What you need to do is tell wordpress to store the images in /srv/www/blog.linformatronics.nl/wp-uploads/2013/01. What your trying to do, it seems, is store images in wp-uploads/blog.linformatronics.nl but the folders should be swapped. It’s the … Read more

How to disable a Custom Post Type Feed?

I’m also getting an error similar to that. The feed links get generated and put into the and that is where your 404 error is coming from. Here’s some code to disable feeds for a custom post type. https://gist.github.com/jaredatch/8610187#file-gistfile1-php <?php /** * Disable the “foo” custom post type feed * * @since 1.0.0 * @param … Read more

Preventing 404 error on empty date archive

You can move the code from OP’s answer into a 404 template filter and force WP to load the date.php file instead of 404.php. It’ll still send the 404 header, but render the page with a different template. function wpd_date_404_template( $template=”” ){ global $wp_query; if( isset($wp_query->query[‘year’]) || isset($wp_query->query[‘monthnum’]) || isset($wp_query->query[‘day’]) ){ $template = locate_template( ‘date.php’, … Read more