I’ve been working on a WordPress project lately that is housed on an Amazon EC2 server, using Bitnami. Overall, it’s a pretty awesome setup, giving me total free reign to setup the server how I need. Everything worked great on the QA server, but for some reason, after we moved the code to the production server, users started complaining about the inability to post any media (images, video, etc.) to their posts. They were getting a permissions error in WordPress trying to create the upload directory.
My initial thought was to use chmod to give all users write permissions to the folder in question. This couldn’t be done, however, as it opens up an obvious security hole.
So Next I checked out the QA site, and realized that the user and group owning the htdocs directory were daemon and bitnami, respectively. This was not the case on the prod server. So it became obvious that WordPress was hitting this directory as the daemon user, and did not have ownership rights to it. So I gave it to them:
chown -R daemon:bitnami /opt/bitnami/apps/wordpress/htdocs
And viola! The issue was resolved. This little jaunt down the rabbit hole, however, got me thinking about permissions as a whole when it comes to WordPress. I did some further reading and came across this great article regarding security on the wordpress platform. I highly suggest you give it a look.
If you only care about the meat and potatoes, as most developers often do, these two snippets are what you want. If you have shell access to your server, you can change file and folder permissions recursively with these bad boys, and set them to the correct permissions the WordPress team suggests.
For Folders:
find /path/to/your/wordpress/install/ -type d -exec chmod 755 {} \;
For Files:
find /path/to/your/wordpress/install/ -type f -exec chmod 644 {} \;
Good luck!
Wow, this on really made my head hurt for a bit.
So I’ve been building a WordPress site hat is using a custom post type of “help.” As you can probably guess, this is for a help section. The data on these help pages is fairly extensive, so I set my post type up to be hierarchical. No problem so far.
Next, I setup a page template for these custom posts (single-help.php). This is where it got a bit tricky; I had three levels of data, all which needed a functional editor so users could input html, and each level needed its own layout, pulling in only its sub posts. So essentially, my page template ended up looking like so (albeit a bit more convoluted).
<?php // setup your arguments: $args = array( // We want to call all posts the custom post type 'help' 'post_type' => 'help', 'posts_per_page' => -1, 'post_status' => 'publish', 'order' => 'ASC', // Next, we want to see if the current post is a parent of any help posts 'post_parent' => $post->ID ); // We then pass these to a wordpress query, and setup our loop $loop = new WP_Query( $args ); ?> <?php if ($loop->have_posts()) : while ($loop->have_posts()) : $loop->the_post(); ?> <!-- This post has children, so we'll list them out --> <a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a> <?php endwhile; ?> <?php else : ?> <!-- This post has no children --> <?php endif; ?>
So basically, this code allowed my single-help file to handle all three levels of the help page hierarchy, loading in each when necessary.
Lemme know your thoughts. I’d love to clean this up a bit more.
Ran into this today with a WP site I was working on. I didn’t want the default version of jquery that’s included now with wordpress, so I found this handy dandy script so that I could load the latest from google. I just added it to the bottom of my functions.php file:
//forcing jquery to load the version we want
function my_scripts_method() {
wp_deregister_script( 'jquery' );
wp_register_script( 'jquery', 'https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js');
wp_enqueue_script( 'jquery' );
}
add_action('wp_enqueue_scripts', 'my_scripts_method');
So I finally got around to setting up Facebook Connect on my site this weekend. Now not only can you like all of my posts individually, but you can login and comment on them via your Facebook profile, and even post your comments to your user page. All this using a bit of FBML, and a nifty widget from Sociable.
I’d like to try and integrate some more aspects in the near future, such as my profile picture, and some better semantic implementation of the Open Graph Protocol.
Now, I just need to figure out how to align my like buttons on my blog with the same URLs that get aggregated to my Facebook page…
Just got this awesome WordPress smiley pack from NoktahHitam here. You can check out the rest of his site here.
Change ≈ to : if you want to use it. E.g. change ≈mrgreen≈ to :mrgreen :