Skip to main content

Update a MySQL table from the command line (find and replace)

I thought this might be helpful to some of you out there, as I routinely have to do this myself. Need to update a table, or a lot of rows of data in MySQL? Here is a handy Find and Replace SQL script to run at the command line.

mysql> update TABLENAME set FIELDNAME  = replace(FIELDNAME, 'X','Y');

In the above example, X is the existing text and Y is the new text you want to replace with. Have fun!

PressPlay Lite WP Plugin is Live

I’ve recently developed a WordPress plugin called PressPlay Lite, which is now hosted on wordpress.org. PressPlay Lite offers music lovers the easiest way to play MP3s on their WordPress site. Simply insert a link to an MP3, and PressPlay Lite will automatically prepend a play/pause button. PressPlay Lite is powered by an extremely slimmed-down version SoundManager 2 (http://shillmania.com/projects/soundmanager2). The simplicity of PressPlay Lite empowers end-users to manage their own audio and rest assured that their guests can listen from any browser on any device.

I have used it on several sites, including my personal music site.

If you’re looking for thee simplest, cleanest, most-flexible way to play music on a WordPress site, please give this plugin a shot. And if you end up liking it – why not make it official? Please submit a rating & review on wordpress.org. Thanks!

UPDATE: Bootstrap Carousel = WordPress Dynamic Content

This is an update to my original post How to make Bootstrap Carousel display WordPress Dynamic Content, so I’ll keep it short…

The Original Source Code

From Twitter.Github.com/bootstrap
[code]

[/code]
Note: Bootstrap developers have added the .carousel-indicators feature sometime after my original post. Below, you will see my solution for generating the “data-slide-to” values dynamically…

Now with WordPress template PHP for dynamic content

[code]




[/code]
Of course you’re free to pass all sorts of arguments within the query_posts('/*your_arguments*/');. I’ve left out “posts_per_page” this time, allowing the default to be whatever you have for Dashboard Settings > Reading > Blog pages show at most = “?” posts.
Note: I’ve removed .active from the .carousel-indicators li, as well as from the .carousel-inner .item. We’ll add it back with jQuery…

Add “active” Class to first items

[code]
<script>
jQuery(document).ready(function(){
$(“.carousel-indicators li:first”).addClass(“active”);
$(“.carousel-inner .item:first”).addClass(“active”);
});
</script>
[/code]
The script must be called after the bootstrap js file, and preferably this is all happening in the footer.

Insert a Paged Blog Loop anywhere in your WordPress theme

[code]
<?php
$temp = $wp_query;
$wp_query = null;
$wp_query = new WP_Query();
$wp_query->query(‘post_type=post&posts_per_page=5′.’&paged=’.$paged); ?>

have_posts()) : $wp_query->the_post();?>


[/code]
Note that the <?php bootstrap_pagination();?> function has already been discussed in our post “Add Twitter Bootstrap Pagination to your WordPress Theme“.

I won’t spend too much time explaining this one. Just know that this will start an independent loop of your choice anywhere you want in your theme templates. And it correctly incorporates wp’s pagination feature, which can be tricky. I primarily use this code in a template I call blog.php. Many clients want either a static home page, or magazine-style home page, but still want a blog-reel displayed elsewhere (a la the common index.php). My blog.php template featuring the above code can be easily added to any internal page of their choice. Of course, there are countless ways to customize the query parameters.