Tag Info

Hot answers tagged

10

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


9

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


7

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/


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


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

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


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

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


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


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

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


2

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


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

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

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


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

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


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

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

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

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

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. https://interconnectit.com/products/search-and-replace-for-wordpress-databases/ Offers a great PHP script that can save you many hours of tedious ...


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



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