Tag Info

Hot answers tagged

4

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 ...


4

You can change it using following code, add it in your theme function.php or in plugin. remove_action ( 'wp_head' , 'rel_canonical' ) ; add_action ( 'wp_head' , 'my_rel_canonical' ) ; function my_rel_canonical () { ob_start () ; rel_canonical () ; $rel_content = ob_get_contents () ; ob_end_clean () ; echo str_replace ( "https:" , ...


3

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 ...


3

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 ...


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 ...


3

Any time you have a duplicate slug for a post or taxonomy, WordPress just adds '-2' to the end of the slug.


3

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

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

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

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'"); ...


2

Your two queries are identical, meaning you only need one of them. The basic solution is: global $testimonials; $testimonials = new WP_Query(array( 'posts_per_page' => 2, /* <-- get both */ 'post_type' => 'testimonial', 'post_status' => 'published', 'orderby' => 'rand', 'ignore_sticky_posts' => true /* you need ...


2

Try to use the following SQL query to fetch duplicate posts: SELECT p2.* FROM wp_posts AS p1 LEFT JOIN wp_posts AS p2 ON p1.post_content = p2.post_content AND p2.ID < p1.ID AND p1.post_type = p2.post_type AND p1.post_status = p2.post_status WHERE p1.post_type = 'post' AND p2.ID IS NOT NULL


1

Download Theme files via FTP Export site content via Tools -> Export Set up a development environment Upload Theme files (and any needed Plugins) to the development environment Import site content via Tools -> Import Make changes on the development site Upload updated Theme files from development site to live site Profit (probably)


1

As far as my understanding you want to make changes in the theme without affecting the main theme so For this purpose the best practice would be creating child theme. So you can edit this child theme and your main theme will be safe. So, you can update the theme safely. Refer to WordpressCodex on creating child theme. Hope this solves the problem.


1

You can try Theme test drive. Here's the plugin description: Theme Test Drive WordPress plugin allows you to safely test drive any theme on your blog as administrator, while visitors still use the default one. It happens completely transparent and they will not even notice you run a different theme for yourself. Best part is you can even ...


1

combining the two answer on this page, I found this worked. $args1 = new WP_Query( array('post_type' => 'post', 'posts_per_page' => -1)); $loop = new WP_Query($args) while($loop->have_posts()) { the_post(); $args2 = array( 'order' => 'ASC', 'post_type' => 'attachment', 'post_parent' => $post->ID, ...


1

In the header loop, store the post id in e.g. $header_post_id In your sidebar: $testimonial_sidebar = new WP_Query(array( 'posts_per_page' => 1, 'post__not_in' => array($header_post_id), // exclude the post in header 'post_type' => 'testimonial', 'post_status' => 'published', 'orderby' => 'rand' )); if ...


1

Easiest way is to install Quick Page/Post Redirect Plugin. Then you'll just have to create a new page with the Title (and Permalink) country when editing this page you'll then have the possibility to redirect it to the other page.


1

I got a very good result using JetPack plugin by WordPress.com's Omnisearch. Install the plugin, activate it using a free WordPress.com account and activate the "Omnisearch" feature. Your tool is ready. Now open the post from where you want to take the post content to search, copy some text and try an Omnisearch with it. If a longer sentence is not ...


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.


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

Simple answer is that you can't as far as the default wordpress installation goes. It's a must to have unique slugs. You can however mess with the Rewrite API with some custom code to hack your way around this & there aren't any plugins(AFAIK) to help you on your way. So it's definitely a lot easier to just force your users to unique slugs


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

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

just add to your query SELECT DISTINCT $wpdb->posts. instead of SELECT $wpdb->posts.


1

You need to do a foreach for the get_the_category Something like: while ($my_query->have_posts()) : $my_query->the_post(); $x = $my_query->current_post + 1; //you can use this to count instead $categories = get_the_category(); foreach($categories as $category) { if ($x == 1) ... //rest of your output // remember to us $category->cat_name; ...


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

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

Demilio, unfortunately the WordPress API seems to assume that custom fields do not have an 'empty' value, in the sense that update_post_meta and delete_post_meta, if given '' as the (previous) meta value perform the update/delete operation for all values for that key. This makes it difficult, for instance, if a custom field key has multiple values ...



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