How to change ‘with_front” key from an existing custom post type?

You could try the newly register_post_type_args filter to adjust it. Here’s an untested example: /** * Set ‘with_front’ to false for the ‘experts’ post type. */ add_filter( ‘register_post_type_args’, function( $args, $post_type ) { if( ‘teachers’ === $post_type && is_array( $args ) ) $args[‘rewrite’][‘with_front’] = false; return $args; }, 99, 2 ); Updated with new info … Read more

Stop WordPress from reserving slugs for media items?

Thank you for the response everyone. I played around with macemmek’s solution and I think it led me to an even better solution: add_filter( ‘wp_unique_post_slug_is_bad_attachment_slug’, ‘__return_true’ ); That is all that is needed. This will automatically ‘skip’ the default assigned slug on any attachment. So an attachment that might normally get the slug “services” will … Read more

How to filter to output of the get_permalink() function

Note that post_link filter is only for the post post type. For other post types these filters are available: post_type_link for custom post types page_link for page attachment_link for attachment The get_permalink()function is actually a wrapper for: get_post_permalink() get_attachement_link() get_page_link() in those cases. Here’s a way (untested) to create a custom wpse_link filter for all … Read more

How to use relative links on my pages?

$my_url=”my/relative/url.php”; echo site_url($my_url); site_url() when used by itself will return the absolute path to your blog. But, if you add an argument to it, as per my example above, it will prepend the absolute path to your path. Just make sure your URL doesn’t contain a leading slash (eg: /this/may/not/work). Finally, if you happen to … Read more

How to get the clean permalink in a draft?

This is a little “hacky”, but when you call get_permalink and you need the permalink for a draft, provide a clone of your post object with the details filled in: global $post; if ( in_array( $post->post_status, array( ‘draft’, ‘pending’, ‘auto-draft’ ) ) ) { $my_post = clone $post; $my_post->post_status=”publish”; $my_post->post_name = sanitize_title( $my_post->post_name ? $my_post->post_name … 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.

Must slugs be unique?

In wp_unique_term_slug(): The $slug has to be unique global to every taxonomy, meaning that one taxonomy term can’t have a matching slug with another taxonomy term. Each slug has to be globally unique for every taxonomy. In wp_unique_post_slug(): @param string $post_status no uniqueness checks are made if the post is still draft or pending […] … Read more

Removing leading zeros from custom permalink structure

How about using custom rewrite tags/structure? So we’ll be using these two rewrite/structure tags: %monthnum2% does the same thing as the %monthnum% tag, but without a leading zero; e.g. 3 and not 03 for March. %day2% does the same thing as the %day% tag, but without a leading zero; e.g. 7 and not 07. The … Read more

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