• I’m working on a site for a client. I’ve set up most of the site in wordpress as “pages,” but there are two sections, “latest news” and “show & class schedule,” that are set up as “posts”; each is its own category, and I’m using the ec3 plugin to manage the display of the event calendar

    Usually, he’ll want to add new posts to manage those two sections, rather than edit a current entry.

    Is there an “edit_post_link” style command, or is it feasible to hack one, that would be something like “add_a_post_in_this_category”?

    When that link was clicked on, the person should be taken to a new post in the admin section, with the category in question already selected.

    I would love to see that! Let me know what you think.

    -Sara

Viewing 3 replies - 1 through 3 (of 3 total)
  • I’d like the same thing myself – i have a few categories with different people posting in each one, so it would be easy (and a bit more foolproof) if their own category had a link to the “write a post” page with their category selected.

    attempting a hack now…

    andrew

    i’ve done something.

    in wp-admin/edit-form-advanced.php around line 100, change

    <div id="categorychecklist">
    <?php dropdown_categories(get_settings('default_category')); ?>

    to


    <?php if ( isset($_GET['postToCat']) ) { $postToCategory = $_GET['postToCat']; } else { $postToCategory = get_settings('default_category'); } ?>
    <div id="categorychecklist">
    <?php dropdown_categories($postToCategory); ?>

    then wherever you want the link in your template (i’ve got it in archive.php inside the post=”metadata” paragraph), add a line like
    Add a <a href="/wp-admin/post.php?postToCat=<?php $category=current(get_the_category()); echo $category->cat_ID; ?>">new post</a> in this category

    WARNINGS:

    • this is an unsupported hack to the core wordpress files. next time you upgrade wordpress you’ll have to be careful that it doesn’t break.
    • there really should be extra error checking in function get_nested_categories in admin-functions.php, because it is now possible to make a post to no category at all.
    • this code only expects one category, so if you have a post assigned to more than one it won’t select them both.
    Thread Starter scormeny

    (@scormeny)

    Cool, Andrew! Thanks for posting this. I will give it a try.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘“add a post in this category” link?’ is closed to new replies.