Hot answers tagged

17

Best to do options, posts, post content and post meta: UPDATE wp_options SET option_value = replace(option_value, 'http://olddomain.com', 'http://newdomain.com') WHERE option_name = 'home' OR option_name = 'siteurl'; UPDATE wp_posts SET guid = replace(guid, 'http://olddomain.com','http://newdomain.com'); UPDATE wp_posts SET post_content = ...


11

The table where your URL is saved is wp_options. You should do an update on the columns that use the URL for your site: UPDATE TABLE wp_options SET option_value = "new domain" WHERE option_name = "siteurl" UPDATE TABLE wp_options SET option_value = "new domain" WHERE option_name = "home" I might be missing some value, but whenever you do this find/replace ...


8

This is a great drop-in script that I use and it works beautifully with the serialized arrays that WP uses to store options. Just make sure to delete it from your remote server when you're done because it's a HUGE security risk. https://interconnectit.com/products/search-and-replace-for-wordpress-databases/


5

I'm not sure this question is WordPress-related. It sounds like it might be handled via .htaccess redirect, or a browser extension. That said: you could try to use the wp_get_attachment_url filter, that is applied to the URL returned by wp_get_attachment_url(). For example: function wpse95271_filter_wp_get_attachment_url( $url ) { if ( 0 === stripos( ...


4

"GUID" stands for "Globally Unique Identifier" mainly used by feeds to tell if that specific post was shown on the feed before or not, even if you change domains. When developing on local host and the moving to live (+1 just for that BTW) and no feed reader/burner has read your feeds and only if that is the case it's OK to change it and start fresh on your ...


4

I modified peteroak's excellent solution to convert to utf-8 and stripped the doctype, html, and body from the ouput. function add_lazyload($content) { $content = mb_convert_encoding($content, 'HTML-ENTITIES', "UTF-8"); $dom = new DOMDocument(); @$dom->loadHTML($content); foreach ($dom->getElementsByTagName('img') as $node) { ...


4

instead of replacing the alt tag you could add-an-attribute-to-a-tag function add_lazyload($content) { $dom = new DOMDocument(); @$dom->loadHTML($content); foreach ($dom->getElementsByTagName('img') as $node) { $oldsrc = $node->getAttribute('src'); $node->setAttribute("data-original", $oldsrc ); ...


3

Sounds like you know what you are doing that's a good start at a migration checklist :) FWIT ... Search and Replace is a very good plugin make sure you have a backup (my plugin DBC Backup 2 can help there) of your SQL database before you run it (just in case) Try to always set you're image and other URLs as relative (then you won't have to ...


3

you do not have to do this , you can use relative paths. when you are linking something instead of subdomain.soemthing.com/image.jpg - use /image.jpg for example like this you won't face the problem in the first place. otherwise for a mysql update statement you can use update TABLE_NAME set FIELD_NAME = replace(FIELD_NAME, ‘find this string’, ‘replace ...


3

I was investigating the issue for this question, and one option is using the plugin Edit Flow. It can be configured to display custom post_status in specific CPT's, but further tests are necessary to see if it applies to this case. Other option is using toscho's Retranslate plugin, where you can define the string to be translated and the post_type: ...


3

I think that the default themes are there to be used. These themes are coded to the standards that should be used and excellent example for new theme authors to learn from. They are also all under the GNU General Public License. I would really think that these are excellent basis to work from when developing a new theme. Why reinvent the wheel when it is ...


3

replace will only replace a row if one of the column values you supply is a primary key or unique index, and that value is identical to an existing row. If your table has neither a primary key or unique index, it will always only insert new rows. You will have to first query for existing data to decide if something should be deleted and a new row inserted. ...


3

First things first, lets clean up your code: <?php $wptitle = the_title(); $wptitle = str_replace('&', 'and', $wptitle);?><?php echo $wptitle; ?> Lets remove the PHP tag spam and put things in nice clean lines: <?php $wptitle = the_title(); $wptitle = str_replace('&', 'and', $wptitle); echo $wptitle; ?> Now if we look at the ...


3

Try this php built-in function array_walk_recursive function wpse_do_something_on_data() { $data = array( 'repeater-1' => array( array( 'user_defined_field1' => 'http://www.domain-001.com', 'user_defined_field2' => 'http://www.domain-002.com', ), array( ...


2

&#38; is essentially synonym of &amp;. In the_title filter wptexturize() runs with priority 1 (important!) and makes this replacement. So by the time it gets to your format_title() at priority 11 - instead of replacing lone & symbol you replace (and break) chunk of &#38; character entity. So you can: move your function to priority 0 and ...


2

What I did was really simple...In the admin panel I left the name as home, then I used conditional statements to change the name. For the navigation I used: <ul> <li <?php if ( is_home() ) { ?>class="current_page_item"<?php } ?>><a href="<?php bloginfo('url') ?>">About Us</a></li> <?php $args = ...


2

For Ques#1, You don't need to use prepare here. Its called upon your data internally. See this line in code here - http://core.trac.wordpress.org/browser/trunk/wp-includes/wp-db.php#L1220 For Ques#2, Why are you updating a post with sql queries? You should be using WordPress API for that - http://codex.wordpress.org/Function_Reference/wp_update_post


2

The _n (see Codex) function accepts four arguments. The first two are texts to be translated (the first is singular, the second plural), the third argument is a number (in this case $count). When $count is 1 the first string is used, otherwise the second string is used. So in fact the first instance of $count is only used to determine whether the single / ...


2

To have a Network enabled shortcode, you only need a Must Use plugin. Just create the folder /wp-content/mu-plugins and drop your code there. From the Codex: Always-on, no need to enable via admin and users cannot disable by accident. Can be enabled simply by uploading file to the mu-plugins directory, without having to log-in. Loaded by PHP, in ...


2

use get_permalink instead of the_permalink and manipulate it however you'd like via php.


2

You can hook to translation filters of Wordpress to change any word or phrase. These filters are: gettext, ngettext and gettext_with_context: add_filter('gettext', 'change_bbpress_wording', 10, 3); add_filter('ngettext', 'change_bbpress_wording', 10, 3); add_filter('gettext_with_context', 'change_bbpress_wording', 10, 3); function change_bbpress_wording ...


2

Okay, this always seems to happen to me. I spend ages looking for an answer and finally decide to give up and post here and then one more search finds enough to solve it. Anyway, this is what worked for me: update wp_posts set post_content = replace(post_content, '[/tab] [tab title="1024x576"] <table class="screenshot-table">', '[tabby title="1024 ...


1

If you are going to do this kind of migration frequently, BackupBuddy would be a good acquisition as it is able to this in a matter of minutes. Anyway, it's important to learn how to move WordPress manually so you can solve any problems that may appear along the way. And for that, this Codex entry is a must read: http://codex.wordpress.org/Moving_WordPress ...


1

WordPress replaces those characters when you are in the VISUAL editor. If you are writing a bunch of code, turn it off, and only write/save in the TEXT or HTML view. EDIT: I just realized the "bulk edit" part of this question. I use a scary but powerful plugin called Search Regex for this type of thing.


1

This one should work add_filter( 'the_content', 'pre_content_filter', 0 ); function pre_content_filter( $content ) { return preg_replace_callback( '|<pre.*>(.*)</pre|isU' , 'convert_pre_entities', $content ); } function convert_pre_entities( $matches ) { return str_replace( $matches[1], html_entity_decode( $matches[1] ), $matches[0] ); } ...


1

The filters you are trying to use run on image insertion, so it is not possible to swap all the images already present in your posts using these filters. It should work, however, if you intend to change to img tags from now on. The filter the_content, however, is applied to the post after it is retrieved from the database and before displaying it to screen. ...


1

In my experience, Superfish actually does not rely on in-page links in order to show the submenus on touch devices (although admittedly I'm basing this solely on iOS devices). Simply tap once on a top-level menu item and its submenu should show. A subsequent tap on the same top-level menu item would cause the browser to load that link.


1

You could do multiple things to get this working: jQuery( '.your-nav-menu-item-class' ).on( 'click', function( e ) { event.preventDefault(); // replace the link here return false; } You could also just use a walker class. Or one of the filters inside wp_nav_menu() - just check the source. Before the Walker: apply_filters( ...


1

Like @milo suggested you can manipulate the return of get_permalink(). This can easily be done via several php string functions, here in use is str_replace(). If you have the need to remove both http:// and https:// give an array of needles to str_replace(). $permalink = get_permalink(); $find = array( 'http://', 'https://' ); $replace = ''; $output = ...


1

Why don't you add a custom button with the functionality you require? You could attach a JavaScript method to do the search and replace as requested? Check out: How to add a custom button to the tinyMCE toolbar? Hope this helps...



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