Support » Fixing WordPress » Link to create new post

  • Resolved Gabriel


    I know that if I wish to create a link for users to create a new post I can do so by i.e.

    <?php if(is_user_logged_in() && current_user_can('read_notice')) : ?>
    <a href="<?php get_bloginfo('url'); ?>/wp-admin/post-new.php?post_type=notice" title="Contribute">Add New</a>
    <?php endif; ?>

    The code above links to creating a new post (post_type notice) but is there a way I can also force what “custom taxonomy” the post is created in? I have a custom taxonomy called “type” in which I have a specific category called “computers”.

    Was thinking maybe:


    but that does not work. Any suggestions assuming it is possible to do.

Viewing 1 replies (of 1 total)
  • Gabriel


    I found a solution to this. Using custom meta boxes one just need to intercept the type=computers, put it in a hidden input field and when saving add it to the appropriate taxonomy.


    <?php if ( isset( $_GET['type'] ) ) { ?>
    	<input type="hidden" name="presettype" id="presettype" value="<?php echo $_GET['type']; ?>" />
    <?php } ?>

    Then when we save our details:

    if ( !empty( $_POST['presetkeyword'] ) ) {
    	wp_set_object_terms( $post_id, $_POST['presettype'], 'type' );


Viewing 1 replies (of 1 total)
  • The topic ‘Link to create new post’ is closed to new replies.