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


5

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/


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

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

You need to use get_field function here instead of the_field. function wrapImagesInDiv($content) { if ( in_category( 'projects' ) ) { $pattern = '/(<img[^>]*class=\"([^>]*?)\"[^>]*>)/i'; $replacement = ' <div class="owl-wrapper"> <div class="owl-item $2"> ...


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


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

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


1

I like to use the Search Regex plugin for mass post editing. http://wordpress.org/extend/plugins/search-regex/



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