WordPress.org

Ready to get started?Download WordPress

Forums

Post title selected from predefined list - is it possible? (5 posts)

  1. timmy0101
    Member
    Posted 6 months ago #

    I want to restrict my users to create posts only with specific titles. I was thinkinig about creating a list of predefined titles and modyfying admin page, so when user creates a post he can select title from a drop-down list... Anyone knows how to achieve this?

    Thank You very much for any help and suggestion!

  2. Sleneau
    Member
    Posted 6 months ago #

    That's something I wouldn't know how do to. But, you could achieve something very similar with a workaround.

    Install the Advanced Custom Fields plugin (probably my favorite WP plugin, as it allows you to extensively customize the UI for making posts and pages). When creating a new set of custom fields for your posts, you can choose to suppress the native content manager AND title field. In their place, you can create a custom field named "Title", and set it to be a dropdown list of predefined titles.

    The catch is that you would have to go into whatever theme you are using, and wherever you the_title(); in any loops, you would have to replace it with the plugin-specific call to that particular piece of metadata.

    I've used the solution before, and it works perfectly. Just note that a lot of plugins depend on the the_content(); filter to run. So, if you're thinking of replacing the regular content field, make sure to call that filter in your theme.

  3. timmy0101
    Member
    Posted 6 months ago #

    Thanks for Your reply Sleneau!
    I've installed ACF Plugin, but I cannot find the option to suppress the native content manager and title field. I can hide everything exept title... Title is required and cannot be hidden using ACF....
    Any clue, am I missing something?

    Thank You!

  4. Sleneau
    Member
    Posted 6 months ago #

    It isn't mandatory, and i'm not sure why ACF doesn't give you an option to remove it.
    Well, either way, paste the function below into your functions.php file to remove the title field from the edit post page on the backend:

    add_action( 'init', 'my_custom_init' );
    function my_custom_init() {
    	remove_post_type_support( 'post', 'title' );
    }
  5. C W
    Member
    Posted 6 months ago #

    You can disable the title (or any built-in feature) for a post type by using remove_post_type_support() (Codex reference).

Reply

You must log in to post.

About this Topic