orphaned taxonomy terms remove by sql query
You shouldn’t need to use a custom SQL query – stick to the built-in method wp_delete_post(). This will also clear out all term relationships too.
You shouldn’t need to use a custom SQL query – stick to the built-in method wp_delete_post(). This will also clear out all term relationships too.
When viewing a single post, get_the_ID(); used within the loop will return the current post’s ID. But I don’t have a reference page that has the list of $query_vars params… Dumping it global $wp_query; var_dump($wp_query->query_vars); would provide such a reference. Where you’d subsequently see that $wp_query->query_vars[‘page_id’] yields the page ID.
The function paginate_links() can return “plain”, “list” and “array” (http://codex.wordpress.org/Function_Reference/paginate_links). Just define the type as array then you’ll be to display it as you want: <?php global $wp_query; $big = 999999999; // need an unlikely integer $paginate_links = paginate_links( array( ‘base’ => str_replace( $big, ‘%#%’, get_pagenum_link( $big ) ), ‘format’ => ‘?paged=%#%’, ‘current’ => max( … Read more
This is an inappropriate use of query_posts() which is only for modifying the main query for the page. Additionally, even if you change your snippet to use get_posts(), your template tags (e.g. the_excerpt()) won’t work as get_posts() isn’t a method of looping through posts, it just returns an array of posts. What you want is … Read more
Try something like: <?php if ( have_posts() ) : ?> <?php while ( have_posts() ) : the_post(); ?> <div class=”parent-post”> <?php the_title(‘<h2>’, ‘</h2>’); ?> <?php $children = new WP_Query( array(‘post_type’ => ‘page’, ‘post_parent’ => get_the_ID() )); ?> <?php if ( $children->have_posts() ) : ?> <ul class=”post-children”> <?php while ( $children->have_posts() ) : $children->the_post(); ?> <li><?php … Read more
Don’t use query_posts(). Don’t modify the main loop query from within the template. You may be able to get a single query to provide what you need (e.g. by filtering pre_get_posts and groupby), but more than likely, you will need to iterate 12 custom loops using WP_Query(). Perhaps something like this: // Get all the … Read more
Assuming you know (or know how to get) the $id (as an integer) of the parent post, use the post_parent parameter: $albums = new WP_Query(array( ‘post_type’ => ‘gallery’, ‘posts_per_page’ => 6, ‘post_parent’ => $id )); Edit Based on this comment: I don’t know the parent post. I want to list the most recent child pages … Read more
This will query all the ticket posts and update a _ticket_date field. However, I’m not yet sure how to retrieve the actual date, so you’ll have to provide me with a little more information for that. Assuming it works properly I would run the following once, and then remove. You could achieve a similar effect … Read more
if you want to keep the row with the lowest id value: DELETE n1 FROM table n1, table n2 WHERE n1.id > n2.id AND n1.meta_key = n2.meta_key OR if you want to keep the row with the highest id value: DELETE n1 FROM table n1, table n2 WHERE n1.id < n2.id AND n1.meta_key= n2.meta_key
No, and in fact you should not include the wp-admin/includes/upgrade.php file in a plugin. There is no real valid use case for doing so. It doesn’t do anything for you or add any useful functions for a plugin. As for your question, you say “it doesn’t work” but you fail to define what that means. … Read more