Admin: Custom Query Returning Permissions Error

I think the problem is that by just appending ?deleteUser=XX you get an ‘illegal’ url, for example: http://localhost/wordpress/wp-admin/edit.php?post_type=type&page=mypage?deleteUser=xxx Instead, use WordPress’ add_query_arg: $url = $_SERVER[‘REQUEST_URI’]; $url = add_query_arg(‘test’,’val’,$url); which gives: http://localhost/wordpress/wp-admin/edit.php?post_type=type&page=mypage&deleteUser=xxx Personally, I wouldn’t use $_SERVER[‘REQUEST_URI’]; and instead hard-code the url of the page using admin_url. Also, see @Joshua comments on using the WordPress in-built … Read more

How to sort by most watched in X days/months

Not sure exactly what you mean by “x days or months”, but I’m assuming you want to set a time interval for the posts that you are querying. I would recommend that you take a look at the “Time Parameters” section in the Codex article on WP_Query. It does an excellent job explain how to … Read more

the_post(); prints out style text into my HTML?

You can view the actions and filters being used in your plugins and themes. I’m assuming something is hooked into the_post action somewhere. Dumping the following globals give you a peek behind the curtain here. global $wp_actions, $wp_filters; Once you identify the source, you either queue up the CSS properly in the HEAD, or remove … Read more

How do I list a custom field and custom taxonomies for each result in a loop?

You can get custom field values with get_post_meta. Like so… <?php $wp_query = new WP_Query(); $wp_query->query(‘post_type=customtype&showposts=10′.’&paged=’.$paged); while ($wp_query->have_posts()) : $wp_query->the_post(); the_title(); // <- works if( $some_meta = get_post_meta( get_the_ID(), ‘the_meta_key_you_want’, true ) { // you could put other formatting here. echo $some_meta; } endwhile; You’ll need to change the_meta_key_you_want in the call to get_post_meta, of … Read more

Single parent post lists child posts with pagination

Something like this should do the trick for ordering by title, and using pagination: global $wp_rewrite, $wp_query; if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <header class=”entry-header”> <h1 class=”entry-title”><?php the_title(); ?></h1> </header><!– .entry-header –> <?php //If top level, find children if($post->post_parent == 0): $children = new WP_Query(array( ‘post_type’=>’page’, ‘post_parent’=>$post->ID, ‘paged’ => … Read more

Why always one post missing

It sounds like you have a filter running on that page that’s adding an offset parameter to your WP_Query. There aren’t any really easy ways to search for all filters. The plugin Hikari Hooks is the simplest that I’ve seen. If you install and activate that plugin and view the problem page, you should be … Read more

Get_the_term_list inexplicably adds values in foreach

The problem lies with the get_the_term_list() function, which is defined with the following arguments: get_the_term_list( $id = 0, $taxonomy, $before=””, $sep = ”, $after=”” ) You’re defining the $before argument as true which PHP prints as 1 so that’s why it’s printing a 1 before the list. You should either remove the argument altogether: get_the_term_list( … Read more