Support » Plugins and Hacks » Remove slug from custom post type » [Plugin: Remove slug from custom post type] Remove Slug Custom post type error!

[Plugin: Remove slug from custom post type] Remove Slug Custom post type error!

  • Hi,

    I’m having this error when i try to add a portfolio (custom post type).

    Remove Slug Custom post type error!
    .htaccess is not writable, please add following lines to complete your installation:
    RewriteRule ^/(.+)$ /$1 [R=301,L]
    RewriteRule ^portfolio/(.+)$ /$1 [R=301,L]

    When I check my htaccess here’s what I found. It’s already written in my htaccess except it has “acf” in the first rewrite.

    RewriteRule ^acf/(.+)/$ /$1 [R=301,L]
    RewriteRule ^portfolio/(.+)/$ /$1 [R=301,L]

    I try to change It and put the code that the error suggested and still having error after I refresh the page.


Viewing 10 replies - 1 through 10 (of 10 total)
  • I got this error too when Adding a New “custom post” like Portfolio, Testimonials, etc.

    I believe, in the end, this doesn’t hinder the Plugins functionality nor is the htaccess file actually un-readable or un-writable.

    The solution for now is to just input a Title for your Portfolio (or other custom post type) and then Save as Draft. Once you have a slug (created from title), the error goes away.

    I think I’ve narrowed the issue down to either this part of code:

    private function add_rules_htaccess() {
    	global $wp_post_types;
    	$suffix = get_option('uwt_permalink_customtype_suffix');
    	$write = array();
    	$htaccess_filename = site_url(). '/.htaccess';
    	if (is_readable($htaccess_filename)) {
    		$htaccess = fopen($htaccess_filename, 'r');
    		$content = fread($htaccess, filesize($htaccess_filename));
    		foreach ($wp_post_types as $type=>$custom_post) {
    			$rewrite_rule = (!empty($suffix))
    						? "RewriteRule ^{$custom_post->query_var}/(.+)/\$ /\$1\.{$suffix} [R=301,l]"
    						: "RewriteRule ^{$custom_post->query_var}/(.+)/\$ /\$1 [R=301,L]";
    			if (strpos($content, $rewrite_rule) == false && $custom_post->_builtin == false)
    				$write[] = $rewrite_rule;
    	else {
    		add_action('admin_notices', array(&$this, 'compatibility_notice'));

    Specifically: “if (is_readable($htaccess_filename))” and either the path to htaccess is wrong (you can see I changed my code to use site_url instead of the ABSPATH in case of an issue there, but that didn’t help)

    OR it’s to due with the next part of code and either the $write variable is empty or the htaccess isn’t writable. I suppose it’s possible that is_writable would return false if there was some sort of restriction with your host and using this PHP function.
    I’m not sure.

    if (!empty($write) && is_writable($htaccess_filename)) {
    	$new_rules = '# BEGIN ' . $this->htaccess_tag . PHP_EOL;
    	$new_rules .= str_replace('$', '\\$', implode(PHP_EOL, $write)) . PHP_EOL;
    	$new_rules .= '# END ' . $this->htaccess_tag;
    	if (strpos($content, "# BEGIN {$this->htaccess_tag}") === false) {
    		file_put_contents($htaccess_filename, $new_rules . PHP_EOL . PHP_EOL . $content);
    	else {
    		$pattern = "/# BEGIN {$this->htaccess_tag}.*?# END {$this->htaccess_tag}/ims";
    		$content = preg_replace($pattern, $new_rules, $content);
    		file_put_contents($htaccess_filename, $content);
    	add_action('admin_notices', array(&$this, 'compatibility_notice'));

    If anyone has any other insight, I’ve love to get rid of this ugly red error for my clients when they add new Custom Post types and use this plugin.
    So Chime in. 🙂


    Thanks for this plugin. I’ve tried this plugin to solve the problem of specific post like “product-review” and it is working just for the already posted “product-review” posts, but not for the new ones. Every time I create a new one, after published I have a 404 error. I’ve tried to save first as a draft, due to the warning referred before, as I also tried to include the rewrite rule on the .htaccess file and no luck 🙁
    Is there anything that I’m missing ?
    Thanks for your help

    Sean, I can affirm that your solution works. Actually, I can publish the custom post type, click anywhere else in the site, than return to the url and get it to show up. Thanks for doing all the digging into the code: when I have some leisure (read: at home time), I’ll experiment further to try to find a solution.

    I wasn’t happy with the permalink structure of the portfolio function in my theme so I installed this plugin to try to change the “folio” in http://fayfitness.com/folio/postname to “services”. Apparently that is not the function of this plugin so I uninstalled and deleted it. Now, after deleting the plugin, when I click on the portfolio entry, it skips the “folio” completely and gives me a 404 error. Did the plugin alter code in my database? I can’t find any changes or anything to fix this problem now and I’m supposed to be releasing this site tomorrow! I tried re-installing and following the instructions above with no improvement.

    Please help, I’ve never had a plugin break my site after uninstalling and I don’t know what else to try! I uninstalled the plugin again and double checked my ftp to be sure the folder was gone.


    I don’t think the plugin altered your database and didn’t clean itself up upon uninstall.

    It sounds like perhaps the plugin edited your .htaccess file and didn’t clean it up at uninstall.

    Try this:
    1) Go to Permalinks Settings page and click Save (technically you don’t need to click Save anymore, as just a visit to this setting does a check).

    OR, if that doesn’t work:

    2) Open your .htaccess file and delete the rule the previous plugin made. If you an find it. If you can’t tell, then make a backup of this file. Delete it from server. Then visit permalink settings page again an click save to hve teh .htaccess file rebuilt.

    Let us know if this helps.


    Ok, I had already tried resetting the permalinks settings in wp and I also deleted and rebuilt the .htaccess file with no success 🙁 The portfolio items are still giving me a 404 error. Any thoughts?


    I went to your site and it looks like it’s working fine.
    Links like this http://fayfitness.com/folio/special-populations/ seem to load just fine with no 404.

    Does it work that way for you?

    Did you do anything new to fix it?
    If so, let us know.


    I ended up putting all the portfolio items in the trash, and then restoring them. Somehow that broke the bug and everything is working fine now!

    Thanks so much for the help!


    I was facing same issue with the plugin, i have solved it, My htaccess file is writable but it was still showing same error mesg.

    – I have changed public function compatibility_notice() and remove div 🙂

    Kalpesh Rathva


    I am getting same problem.
    After activation of this plugin when i upload new products than i am getting page not found error

    Please suggest me ASAP…….

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘[Plugin: Remove slug from custom post type] Remove Slug Custom post type error!’ is closed to new replies.