WordPress.org

Ready to get started?Download WordPress

Forums

Add a New Post button on category view (4 posts)

  1. vahyd
    Member
    Posted 2 years ago #

    I want to add a button on category view so that when the button is pressed it sends the users to Add New Post page WITH the current category checked by default. I dont want the users to manually select the category checkboxes if they were redirected from a category view.

  2. Jacob Chappell
    Member
    Posted 2 years ago #

    Well, the way to do that would be to use $_GET data from the URL. WordPress does this by default for a few fields (for example the title). If you pass the query string ?post_title=Title to the edit-post URL, it will auto-populate the title field.

    The problem is, I don't think it does this by default for the post category. You would have to write a plugin that intercepts the category checkbox list output and alters it based on $_GET data (also not sure if there's a hook for that).

  3. vahyd
    Member
    Posted 2 years ago #

    I think it should be like /post-new.php?cat_ID=2 or something like this.
    I've gone through the post-new.php and edit-form-advanced.php on notepad but i couldn't figure it out. I'm not too good at php.

  4. Jacob Chappell
    Member
    Posted 2 years ago #

    I've browsed through the source and tracked it down to the function wp_terms_checklist in the file /wp-admin/includes/template.php. Unfortunately, I still don't see any indication that any $_GET data is actually taken into account to determine which boxes are checked.

Topic Closed

This topic has been closed to new replies.

About this Topic