Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have a custom post type called newsletter. Once the newsletter is created I want to create a link to download the newsletter from the admin section (the newsletter post type is not accessible from the front end of the wordpress site). When the download link is clicked it will run a function in my plugin. The question is how do I register a url with wordpress that will do such a thing? I'm sure this is something pretty simple and I'm just missing it.

share|improve this question
    
Are you specifically wanting permalinks and pretty URLs? If so you could have a huge uphill battle depending on the form you want to take. Or do you mean how would you implement the button and how to place it in the backend? If you could clarify further with examples diagrams etc it would help greatly –  Tom J Nowell Jan 16 '13 at 17:00

1 Answer 1

up vote 2 down vote accepted

You want (probably) add_submenu_page. The first parameter-- the one listed as $parent_slug in the Codex is going to be edit.php?post_type=your-post-type-name, like this (mostly cribbed from the Codex page):

function add_submenu_wpse_81844() {
  add_submenu_page( 
      'edit.php?post_type=your-post-type-name'
    , 'My Custom Submenu Page' 
    , 'My Custom Submenu Page'
    , 'manage_options'
    , 'my-custom-submenu-page'
    , 'my_custom_submenu_page_callback'
  );
}
add_action('admin_menu', 'add_submenu_wpse_81844');

Check the Codex for what the other parameters mean.

share|improve this answer
    
thanks that's what I needed. Do you know if there is a way to create a submenu without it showing in the sidebar? Basically this link will only be used to download the newsletter which is accessed through a button when the posts are listed. –  greatwitenorth Jan 17 '13 at 17:15
    
I believe you can pass null as the first parameter. See the Codex page. –  s_ha_dum Jan 17 '13 at 17:24
    
yes you can do null. In my case I set it to options.php which achieves the same results. thanks. –  greatwitenorth Jan 17 '13 at 17:45
    
one other small issue. Is there a way to prevent the admin theme from being output? Since I'm streaming a zip file to the client, I don't want the admin wrapper. I didn't see anything on the codex page about it. –  greatwitenorth Jan 17 '13 at 17:51
    
For anyone interested the above question about the admin wrapper ended up getting answered here: wordpress.stackexchange.com/questions/82041/… –  greatwitenorth Jan 18 '13 at 15:11

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.