Code fails in plugin file but works in functions.php

You need to use a hook and a function in your plugin file. For example: function sher_posts() { $pages = get_posts($args); foreach($pages as $page) { $out = get_permalink($page->ID); } } add_action(‘wp’, ‘sher_posts’); Of course this example doesn’t know what $args are or what to do with $out.

Change category checkbox into radio button [duplicate]

I find this function admin_js() { ?> <script type=”text/javascript”> jQuery(document).ready( function () { jQuery(‘form#post’).find(‘.categorychecklist input’).each(function() { var new_input = jQuery(‘<input type=”radio” />’), attrLen = this.attributes.length; for (i = 0; i < attrLen; i++) { if (this.attributes[i].name != ‘type’) { new_input.attr(this.attributes[i].name.toLowerCase(), this.attributes[i].value); } } jQuery(this).replaceWith(new_input); }); }); </script> <?php } add_action(‘admin_head’, ‘admin_js’);