Custom post type 404s with rewriting even after resetting permalinks

Step 1, add the rewrite tags for custom event year and month query vars, then register the event post type with those tags in the slug argument of the rewrite argument: function wpa83531_register_event_post_type(){ add_rewrite_tag(‘%event_year%’,'(\d+)’); add_rewrite_tag(‘%event_month%’,'(.+)’); register_post_type( ‘event’, array( ‘public’ => true, ‘rewrite’ => array( ‘slug’ => ‘events/%event_year%/%event_month%’ ), ‘has_archive’ => false, ‘hierarchical’ => false, ‘supports’ … Read more

Setting 404 page in Nginx

Remove the ‘fastcgi_intercept_errors’ argument from you configuration. It’s unnecessary since ‘error_page’ declares 404 errors, which should be handled by index.php, which will trigger PHP-FPM to handle it, and WordPress to present your theme’s 404 page. It seems counter-intuitive, but ‘fastcgi_intercept_errors’ is actually causing PHP not to handle the error page.

Display search results within the same page

The simplest option if you want to show search results within a page context you’ll need to do a custom loop, otherwise you won’t be able to access the page information. Change the input with the name s to something else like search or q to stop wordpress from doing it’s usual built in search. … Read more

How do I programmatically generate a 404?

function generate_404_somehow() { global $wp_query; $wp_query->is_404 = true; } add_action(‘wp’,’generate_404_somehow’); Of course, that will send all of you page to the 404 template. I don’t know what the conditions are that this should fire or not fire. Or to be more cautious (see comments) … function generate_404_somehow() { global $wp_query; $wp_query->set_404(); } add_action(‘wp’,’generate_404_somehow’);

How to get permalinks with category base working with sub-categories

I was able to get this to work pretty easily actually. I am now able to have my category base in my permalinks. This allows me to now have URLs like: http://www.new1450.dev/industries/ {Main blog post only showing category selection} http://www.new1450.dev/industries/development/ {a parent category} http://www.new1450.dev/industries/development/parent-category-i/ {child of parent} http://www.new1450.dev/industries/development/parent-category-i/child-category-i/ {child of child} http://www.new1450.dev/industries/development/parent-category-i/child-category-i/some-cool-post/ {actual post} This … Read more

How to Change 404 page title

I would use the wp_title filter hook: function theme_slug_filter_wp_title( $title ) { if ( is_404() ) { $title=”ADD 404 TITLE TEXT HERE”; } // You can do other filtering here, or // just return $title return $title; } // Hook into wp_title filter hook add_filter( ‘wp_title’, ‘theme_slug_filter_wp_title’ ); This will play nicely with other Plugins … Read more

Inconsistent temporary 404s on whole install | PHP error with post-template.php

There are two types of 404 errors: WordPress-generated, and server-generated. In some server environments, 404s could be inaccurately displayed by the server in cases of CPU overload or due to certain instances of misconfiguration, etc. Usually server-generated 404 errors will say something like “Nginx” or “Apache” at the bottom of the page (depends on server … Read more

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