Is it necessary to reset the query after using get_posts()?
No. get_posts() does not modify global $wp_query variable and it doesn’t need to be cleaned up. Note that if you further use setup_postdata() you do need to wp_reset_postdata() afterwards.
No. get_posts() does not modify global $wp_query variable and it doesn’t need to be cleaned up. Note that if you further use setup_postdata() you do need to wp_reset_postdata() afterwards.
Plugin It’s basically just a user capability check, followed by a redirect in an exit call. It then redirects to the site the request came from. <?php ! defined( ‘ABSPATH’ ) AND exit; /* Plugin Name: (#66093) »kaiser« Deny Admin-UI access for certain roles */ function wpse66093_no_admin_access() { // Do not run if the user … Read more
Some additional information, no need to count the posts again, because WP_Query already did that for you. To clarify this, some information from the Class Reference of WP_Query as found in the »Properties« section: $post_count The number of posts being displayed. $found_posts The total number of posts found matching the current query parameters What this … Read more
You can’t apply templates to custom post types in this manner. That will show up only if the post type is ‘page’ ( Check the wp-admin/includes/meta-boxes.php line 568 ). However if you want to style all your single custom post types in the same manner but different from other post types you could use the … Read more
If you need to get the wordpress version in your script, there is a global variable: $wp_version (right now it’s something like ‘3.1-RC3-17376′) It contains the wordpress version. If you need to acquire if from a file, you can read it from /wp-includes/version.php: function getWPVersion() { $path=”/path/to/wp-install”; include $path.’/wp-includes/version.php’; return $wp_version; } WordPress Version Variables … Read more
Thanks Chip (excellent Settings API tutorial) and t31os (great snippet of code for quick testing) for both your suggestions. I did some further digging and found that the default messages can indeed be displayed if I hook into any menu but only if the function settings_errors() is called. For example, modifying t31os code as follows: … Read more
The error message shows that the class description_walker extends the Walker_Nav_Menu class and overrides the start_el() method, but the signature differs from the method definition in the parent class. As mentioned in comments, it would be best to contact the developer of your theme and ask for a corrected version of the theme. If the … Read more
I’ve defined a variable – let’s call it $header_var, which is placed in the header.php file. I would like this variable to be passed onto my template file (in this case taxonomy.php). global is not a very recommended way to do the trick, but it works if you use it properly: put it before to … Read more
I fixed it!!! Woohoo. Using this link – link to patch I edited the line it advises and it works fine.
Aha, so the $before_widget variable is a string representing div element: <div class=”widget my” id=”my-widget-1″> . So I checked the $before_widget for the “class” sub-string and added my $widget_width value to it. The code is from my custom widget file: function widget( $args, $instance ) { extract( $args ); … //other code $widget_width = !empty($instance[‘widget_width’]) … Read more