Last active
December 30, 2022 04:33
-
-
Save hayskytech/ebfef8cf9609f2f766c96ad31dda1484 to your computer and use it in GitHub Desktop.
preselect-category-new-post.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function ws_preselect_post_category() { | |
if ( isset($_GET['category']) && is_numeric($_GET['category']) ) { | |
$catId = intval($_GET['category']); | |
?> | |
<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'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment