Tag Info

Hot answers tagged

5

Use a run-once script to clean it up. Just an outline, no code: Get all posts. See get_posts( array ( 'numberposts' => -1 ) ) For each post get all attachments. See get_children( array ( 'post_type' => 'attachment', 'numberposts' => -1 ) ) For each attachment get the attachment URL. See wp_get_attachment_url() If you find the attachment URL in the ...


3

One way would be to keep track of which years you've already printed. Using your code: <?php $args = array( 'post_type' => 'attachment', 'post_mime_type' => 'image', 'numberposts' => -1, 'orderby' => 'menu_order', 'order' => ASC ); $attachments = get_posts( $args ); echo '<table ...


2

You can actually use a single index.php to create your WordPress theme. all you need is a style.css and index.php (along wit footer and header) it is all up to theme developer. I did that for old style classic bloc design a lot, but today, while designing complex CMS and Magazine themes; using different files according WordPress Template Hierarchy makes ...


2

Theme template files are organized in this way because of the WordPress Template Hierarchy. Since all primary template files eventually fallback to index.php, it is certainly possible to use only the index.php primary template file. There are advantages and disadvantages to using either method. Generally speaking, the usefulness/efficiency of defining ...


2

I sometimes use this plugin http://wordpress.org/extend/plugins/duplicator/ it works pretty well if your server enviroment meets it's requirements. Otherwise, it's the good ole, mysql dump route that the other guys explained.


2

I don't believe it's covered by WP magic; and lately there's been much discussion of how bad it can be performance-wise to use %postname% alone, for example http://digwp.com/2011/06/dont-use-postname/ You might have better luck with %year%/%postname. Best of luck!


2

that could be caused by post revision being saved, and you should use wp_insert_post_data anytime you want to do something before the post is saved, here is an example plugin i just cooked up to test it and it looks like this: <?php /* Plugin Name: wpse37901 Plugin URI: http://en.bainternet.info Description: answer to ...


1

To answer the question directly, there is $wpdb->update but nothing that will strictly duplicate INSERT IGNORE that I know of. If $wpdb->update, does not work I am fairly sure that you will need to write your own query and use $wpdb->query and $wpdb->prepare.


1

Import the new table as wp_posts_2, then join them and delete all duplicates based on post_content; then merge the two tables. The following SQL query (untested!) should give the posts from the new table to be deleted: SELECT wp2.* FROM wp_posts_2 as wp2 LEFT JOIN wp_posts as wp ON wp2.post_content = wp.post_content WHERE wp2.post_content = wp.post_content ...


1

Welcome to the lions den So you're willing to get down into the blazing furnace or the lions den and change the upload path. This is so not a good idea without investigating what is happening behind the scenes. I can't give you a full write up, as there's so much involved, like filters, options calls, constants, etc. but I can give you one recommendation: ...


1

Based on several different answers, with a SPECIAL thanks to EAMann's similar answer - here's the method I followed. Using new WP_Query instead of query_posts for this page. Defining the query variable ($main_query) as global. Querying a temp array ($temp_featured) with my featured posts. Creating an array with only the IDs of the `$temp_featured'. Note ...


1

There's plugin to do that - Duplicate Post While viewing a post as a logged in user, you can click on Copy to a new draft as a dropdown link under Edit Post in the admin bar. This will lead you to edit post page, change whatever you want and save. It'll save it as different post. - Quote for plugin Description


1

As @helenhousandi said, why not use the WP_Query, try this: <?php // the args for the WP_Query // See more @http://codex.wordpress.org/Class_Reference/WP_Query $args = array( 'post_type' => 'matches', 'meta_value' => 'Shen', 'order' => 'DESC' ); ?> <?php $the_query = new WP_Query( $args ); ?> <?php if( ...


1

Pass the post ID from the first query as a post__not_in parameter to exclude it from the second query. $nature_loop_1 = new WP_Query( array ( 'category_name' => 'nature', 'tax_query' => array ( array ( 'taxonomy' => 'highlight', 'field' => 'slug', 'terms' ...


1

This script will grab all of the attachments in the database, compare the file to one another through md5 and if it finds a duplicate and it has a 1 at the end of the file name it will remove the image: require('wp-load.php'); global $wpdb; $img_posts = $wpdb->get_results("SELECT * FROM {$wpdb->prefix}posts WHERE post_type like 'attachment'"); ...


1

You can hook 'save_post' or 'wp_insert_post' (both executed the same in wp_insert_post()) to check for autosaves and notify the author(s) accordingly. The checks that I would do would be to check that the author of the autosave (aka, revision) and the new autosave are not the same, check that the post title is the same and that the content is SIMILAR, to do ...


1

Seems like a silly question, but are there exactly 2 users in the database? Or are there more. The only thing I can see happening is because you are setting to 3, it's looping back through. Another thing to try is checking the peterpanpan user, to see if he has the custom_role twice in his user_meta.



Only top voted, non community-wiki answers of a minimum length are eligible