Custom post type, when type non existing post name, it query the nearest possible post name by default. How can I disabled this behavior

Out of the box, WordPress will try to be helpful and provide the next best post if it cannot find the one you specified – in your case example/t. This feature can be deactivated, however: function stop_404_guessing( $url ) { return ( is_404() ) ? false : $url; } add_filter( ‘redirect_canonical’, ‘stop_404_guessing’ );

Custom Post Type, 404 error

I solved by eliminating the following portion of code: I don’t remember why I had to code it, it apparently solved an issue, even if I don’t remember what issue. The portion is the following: add_action(‘pre_get_posts’, function ($query) { if (!is_admin() && $query->is_main_query() && empty($query->query_vars[‘suppress_filters’])) { if (is_archive()) { if (is_category()) { $query->set(‘post_type’, [‘post’, ‘docs’]); … Read more

Can I have a specific template for products even if they are standard posts and not CPT?

Filter template_include, check if the current post is a product and load the product template. Example: add_filter( ‘template_include’, function( $template ) { if ( ! is_singular() or ! get_post_meta( get_the_ID(), ‘price’, true ) ) return $template; return locate_template( ‘product-single.php’ ); }); How exactly you determine if a post is a product is up to your … Read more

affiliate linking from wordpress [closed]

I wrote a plugin (“AmazoLinkenator”) that automatically adds your Amazon afilliate link to all Amazon links – overwriting any existing Amazon affiliate link that others might place in a comment. The techniques in there could be added to to do other affiliate places. Found here: https://wordpress.org/plugins/amazolinkenator/ It has options to shorten via Bit.ly your links, … Read more

Blog url disappears

Because this is how WP is set. You have set your permalinks structure to /%category%/%postname%/ so when you click on a post link, you will have that post /%category%/ and then /%postname%/. I guess you wished to have a structure like /blog-page/%category%/%postname%/. well just add this to your permalink settings /blog-page/%category%/%postname%/.