Tag Info

Hot answers tagged

7

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


6

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


4

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


3

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

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. http://interconnectit.com/124/search-and-replace-for-wordpress-databases/


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

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


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

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

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


1

I too would recommend using a script like the one @lancemonotone mentioned earlier in order to avoid problems with certain widgets and plugins being affected by not serializing the URLs as you replace them. http://interconnectit.com/124/search-and-replace-for-wordpress-databases/ Offers a great PHP script that can save you many hours of tedious rebuilding ...


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

You code works where the function the_excerpt is used. It does not work when get_the_excerpt is used, which does not apply the the_excerpt filter. It applies get_the_excerpt instead. Using get_the_excerpt will cause the filter to apply to both the cases since the_excerpt() uses get_the_excerpt(). Automatically generated excerpt content is a different thing ...


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

Just do this with your string: $yourString = preg_replace ( '/å/' , 'a' , $yourString ) $yourString = preg_replace ( '/ä/' , 'a' , $yourString ) $yourString = preg_replace ( '/ö/' , 'o' , $yourString ) If you just want to do it with an SQL sentence, then you can try this : REPLACE(REPLACE(REPLACE(StringColumn, 'å', 'a') , 'ä', 'a') , 'ö', 'o') And you ...


1

You could work with a white-list and replace the regular expression with something more readable: add_filter( 'nav_menu_css_class', function( $classes ) { $allowed = array( 'menu-item-has-children', 'current-menu-item' ); $output = array(); foreach ( $classes as $class ) { if ( in_array( $class, $allowed ) ) ...


1

Background: The guid should be just what the name says: a globally unique identifier. A unique string or number, not related to a public address at all. However, some functions, namely for images, are still using it for URLs. There are plans to fix that somewhere in the future, see #6492. For now, you can safely change the value of that field, as long as ...


1

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


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

Just to add to the answer above, I agree 100% that those are a good basis, I try to use the yearly new theme every time, since all the new features will be implemented in it, and I can just pick what I leave out or not. Anyway, I've done this many many times and I believe it's not as painstaking as a task as Pieter suggests. You can get this done in 15min ...


1

This belongs to stackoverflow. Here's a solution anyway: $content = preg_replace_callback('/\%replaceContent:{(.*?)}\%/', 'do_replacements', $content); function do_replacements($matches){ $type = $matches[1]; // here's your {type} $replacement = "...replacement for {$type}"; return $replacement; }


1

There are no filters for the plugin's output and this plugin wasn't built as a class (where you could technically extend the class and override the parent methods). If you're wanting to change the front-end elements only, you can use jQuery to do your bidding. If you need to add additional processing on the backend, you're out-of-luck with this plugin ...


1

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


1

To change the wordpress domain what we often need, may be to make the site live from localhost: This is a complete list of update queries: UPDATE wp_posts SET guid = replace(guid, 'http://olddomain.com','http://newdomain.com'); UPDATE wp_posts SET post_content = replace(post_content, 'http://olddomain.com', 'http://newdomain.com'); UPDATE wp_links SET ...


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

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


1

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



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