Restore WordPress database on a new server

October 1, 2013

[this post will be properly edited]

I was creating the new database and WordPress would tell me to install the site.

Solution: dropped the database and created it from ‘mysql’ prompt.

user$ mysql -u root -p’yourpassword’ -h localhost
mysql> create database your_database_name;
mysql> exit
user$ mysql -u root -p’yourpassword’ -h localhost your_database_name

Permalinks WordPress

September 25, 2013

So far, I found myself trying to solve the same problem on different machines.

EC2 amazon Ubuntu instance. In this one I had to modify http.conf.

Ubuntu server 12. Here I installed apache2 so the approach was a bit different.

Permalinks on WordPress (Ubuntu)

1) Enable Mod Rewrite : sudo a2enmod rewrite
2) Change AllowOverride None to AllowOverride All : sudo nano /etc/apache2/sites-enabled/000-default
3) Restart Apache : sudo /etc/init.d/apache2 restart

Permalinks on WordPress (amazon EC2)

February 17, 2013

Motivation: in my particular case I moved a WordPress site from Bluehost to amazon’s EC2. Permalinks were not working.
Solution: I had to modify the override option from my httpd service.

  1. Go to /etc/httpd/conf and edit httpd.conf
    1
    2
    3
    4
    
    <Directory />
        Options FollowSymLinks
        AllowOverride All
    </Directory>
    <Directory />
        Options FollowSymLinks
        AllowOverride All
    </Directory>
  2. Change also AllowOverride if it is set to None.
    1
    2
    3
    4
    5
    
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   Options FileInfo AuthConfig Limit
    #
        AllowOverride All
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   Options FileInfo AuthConfig Limit
    #
        AllowOverride All
  3. I you haven’t created it yet, place in the root directory of your wordpress installation a .htaccess file with the following contents:
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    
    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
     
    # END WordPress
    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    
    # END WordPress

Source: this post.

remove_filter function in WordPress

March 24, 2012

Motivation: In a specific website I am using the simplex theme. If one tries to place a static page as home instead of the blog, simplex keeps showing the Home page.
Solution: as you can see, people have already reported this. But in the current version of the theme the line is introduced in functions.php and functions are not really overridden, they can be just replaced.
In the codex it is described how to remove actions and filters but it turned out that the solution didn’t work for me. As usually, it was really easy but cost me a bit to figure out:

1
2
3
4
5
6
function unhook_simplex_function() {
    if(has_filter( 'wp_nav_menu_items', 'simplex_nav_menu_items' )){
        remove_filter( 'wp_nav_menu_items', 'simplex_nav_menu_items' );
    }
}
add_action('init','unhook_simplex_function');
function unhook_simplex_function() {
    if(has_filter( 'wp_nav_menu_items', 'simplex_nav_menu_items' )){
        remove_filter( 'wp_nav_menu_items', 'simplex_nav_menu_items' );
    }
}
add_action('init','unhook_simplex_function');

Instead of calling the remove_filter function directly in my functions.php I just added an action that calls the function that will remove the filter from the ‘init’.

WordPress in Spanish

Motivation: it’s pretty simple. I just wanted to create a WordPress site in Spanish.
Solution: download the file from the source specified below. Extract the file es_ES.mo and place it in /wp-content/languages/. Finally, change the file wp-config.php in the root directory to point to Spanish language: define ('WPLANG', 'es_ES');
Source: http://es.wordpress.org

Orphan next post arrow in Safari and Chrome

February 26, 2012

Motivation: in the single post page, the arrow that points to the next post appears one line below the ‘Next’ text in Safari and Chrome browsers.
Solution: I don’t know if this is a ‘good’ way to solve it or if I should report it somewhere, but as a quick fix I’ve edited my child style.css file adding the following:

1
2
3
4
5
6
#nav-single .nav-next {    
    float:right;
}
#nav-single .nav-previous {
    float:left;
}  
#nav-single .nav-next {    
    float:right;
}
#nav-single .nav-previous {
    float:left;
}  

WP-reCAPTCHA: javascript error in pages without submit button

February 5, 2012

[UPDATE]: it seems that the problemis solved since version 3.1.5 (but I’m not certain if this is version 3.1.5 or since 3.1.6. Anyway, you don’t need to read this post if you are using one of those versions or above.

Motivation: I’m using the WP-reCAPTCHA plugin and there is a javascript error in every page where I didn’t include any post comment box.
Solution: Found here. But I’m copying the solution here anyway:
“In the recaptcha.php page, there’s a function called “save_comment_script”. In the middle of it is a block of code that currently looks like this”

<script type="text/javascript">
var sub = document.getElementById('submit');
document.getElementById('recaptcha-submit-btn-area').appendChild (sub);
document.getElementById('submit').tabIndex = 6;
if ( typeof _recaptcha_wordpress_savedcomment != 'undefined') {
	document.getElementById('comment').value = _recaptcha_wordpress_savedcomment;
}
document.getElementById('recaptcha_table').style.direction = 'ltr';
</script>

Change that code to look like this:

<script type="text/javascript">
if(document.getElementById('submit') != null)
{
	var sub = document.getElementById('submit');
	document.getElementById('recaptcha-submit-btn-area').appendChild (sub);
	document.getElementById('submit').tabIndex = 6;
	if ( typeof _recaptcha_wordpress_savedcomment != 'undefined') {
		document.getElementById('comment').value = _recaptcha_wordpress_savedcomment;
	}
	document.getElementById('recaptcha_table').style.direction = 'ltr';
}
</script>

Tags

Code Snippet (second part)

February 1, 2012

Motivation: I didn’t like the first code snippet plugin that I used because you had to edit the code in a different place than the post edition.

Solution: Now I’m using the Better WordPress Syntax Highlighter plugin. It is very easy to use in the post edition, you only need to add a specific <pre> tag.

Tags

Code Snippet

January 28, 2012

Note: this post is deprecated, I moved to another plugin, see this new post.

Motivation: I want to publish code into my posts. I’m not really motivated to search or code anything so I’ll go for a plugin this time.

Solution: I found this plugin called “WordPress Code Snippet” which for me it’s okay. Maybe in the future I’ll search for another solution but right now it does the trick.

Tags