• I am currently building a website where I want to be able to hide parts of the post editor. I am using the custom post type and advanced custom fields to create posts that I can fill out the custom fields for. I want to hide the editor and the title so the only thing showing is what I want to fill out. I was able to hide the editor and title by calling remove_post_type_support. The only problem is I can no longer publish anything. Everytime I hit the green publish button it does everything it should. Even says view post but the view leads no where and the new entry isn’t in the list of entries for the post.

Viewing 12 replies - 1 through 12 (of 12 total)
  • Moderator bcworkz

    (@bcworkz)

    You could leave the editor support in and use admin CSS to just hide editor components. For example:

    .edit-post-visual-editor, .edit-post-text-editor, .edit-post-header__toolbar {
        display: none;
    }

    Add ".post-type-{$post_type}" (from the edit screen’s body tag) selector in front of each of the above selectors to only hide the editor for that one post type.

    Some clever user could cause the editor to be displayed for them again, but if you’re not using post content, it wouldn’t do them any good to use the editor.

    Thread Starter lex713

    (@lex713)

    @bcworkz would I be able to do this by using the add admin css plugin. I have never used css. So would I just copy and paste the code you wrote in and if i want to pick which post I add .post type?

    Moderator bcworkz

    (@bcworkz)

    I’m not familiar with that plugin, but it sounds promising. Give it a try! I’m not sure what the UI of that plugin is like, but I’d expect you to be able to paste my suggested CSS in the appropriate place and editor will then be hidden.

    The above code as-is hides the block (Gutenberg) editor (not classic or any other editor types) for all post types. Adding ".post-type-{$post_type}" in front of each selector will limit the hiding to only that post type. If you want to hide the editor of regular blog posts, the “post” post type, the CSS ends up being:

    .post-type-post .edit-post-visual-editor,
    .post-type-post .edit-post-text-editor,
    .post-type-post .edit-post-header__toolbar {
        display: none;
    }

    This will hide the editor for all users. Hopefully that’s not a problem. If that plugin is extra cool, it’d have a way of applying CSS by user role. I’m not very hopeful that it would do that. If an admin needs access to the editor, they could temporarily deactivate the plugin, but then all other users would also see the editor as long as the plugin is deactivated.

    If you were to add the CSS through your own custom coding, it could be done conditionally by role. But it all gets rather involved. If you’re new to even CSS, you’d probably prefer to avoid this.

    One other thing — the addition of new CSS often gets sidetracked by caching schemes. If nothing seems to be working, flush your browser’s cache and that of any caching plugin you might have on the site.

    Thread Starter lex713

    (@lex713)

    @bcworkz Plugin didnt end up working. What I ended up doing is just putting it in apperance->edit css. It ended up only getting rid of the title. I want to get rid of the text that says start writing or type and I also want the bar at the top gone that has settings, publish and all that. I believe it is the toolbar which means something I did didn’t work.

    Thread Starter lex713

    (@lex713)

    @bcworkz The title doesnt work either forgot to disable a code snippet before testing.

    Moderator bcworkz

    (@bcworkz)

    A little hacky, but this seems to work:

    add_action('admin_print_scripts', function(){
      echo '<style>.post-type-post .edit-post-visual-editor,
    .post-type-post .edit-post-text-editor,
    .post-type-post .edit-post-header__toolbar {
        display: none;
    }</style>';
    });

    I added it to a custom plugin I use for testing. It should work from functions.php of a theme (or preferably a child theme) as well.

    Hacky because it bypasses the recommended enqueuing step. This means the CSS may not be positioned in the optimal place on the page. Saves us from needing additional coding though.

    Thread Starter lex713

    (@lex713)

    @bcworkz I’m sorry I am fairly new to this so I paste that in the function.php. I can’t paste it there but I don’t want to get into being able to paste it and messing with the security. Until I know that’s the place to do it.

    Moderator bcworkz

    (@bcworkz)

    I pasted my suggested code into my current theme’s functions.php file, at the very bottom. That worked on my site to hide the block editor on post edit screens. You do get a scary warning about editing active themes. It’s a valid warning, because saving erroneous code will lock you out of WP and the only recovery is to use FTP to undo the change.

    If you want extra safety, first switch to another theme, then add the code to your now inactive theme. If there are any errors, you will not be able to reactivate your theme, but you can still edit it to undo or fix any error.

    Another reason to not edit an active theme is if it is subject to updates, your added code will be overwritten when the theme is updated. Custom code is best kept in a child theme or custom plugin.

    Thread Starter lex713

    (@lex713)

    @bcworkz I cant figure out how to change the function.php permission so I can edit it. If I do it thru firezilla I can’t access the theme folders. I tried using code snippet and it didn’t work.

    Moderator bcworkz

    (@bcworkz)

    If you don’t have file system permissions for themes and plugins folders, there’s nothing you can do unless you’re the hosting account holder. The account holder should be able to alter folder permissions through the hosting file manager if not through FTP. If you are the account holder and cannot do so, please ask your host for assistance. There’s nothing that can be done in this regard from the WP end of things.

    Thread Starter lex713

    (@lex713)

    @bcworkz i believe I am the hosting account holder. I also believe I am hosting thru WordPress. I bought the business account.

    Moderator bcworkz

    (@bcworkz)

    The .org version of WordPress which we support here does not provide hosting. The .com version does. If you site is hosted by wordpress.com, that is supported at https://wordpress.com/support/

    While it’s the same base software, there are fundamental differences, so cross support is not feasible.

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Green publish button won’t publish’ is closed to new replies.