Create a post automatically associated to a category in wordpress
Question
Hello guys I have many categories (Press release, News letter, Media Resources )when the client wants to create a Pressrelease post the one has to associate the post with that category, is there a way with code or a plugin to say “Add Press release” and create a post automatically associated to the category, or preselect the category?
Something like that?
Im using this code:
// Preselect category
function ws_preselect_post_category() {
if ( isset($_GET['category_id']) && is_numeric($_GET['category_id']) ) {
$catId = intval($_GET['category_id']);
?>
<script type="text/javascript">
jQuery(function() {
var catId = <?php echo json_encode($catId); ?>;
jQuery('#in-category-' + catId).click();
});
</script>
<?php
}
}
add_action('admin_footer-post-new.php', 'ws_preselect_post_category');
function ws_add_new_post_link() {
add_posts_page(
'Add New JS Article',
'Add New JS Article',
'edit_posts',
'post-new.php?category_id=19'
);
}
add_action('admin_menu', 'ws_add_new_post_link');
0
4 months
0 Answers
10 views
0
Leave an answer
You must login or register to add a new answer .