Check if post of title already exists

Yes $wpdb is built in and is loaded by the WordPress Core on every page load. I don’t see any critical problem with your code. I am going to suggest some improvements because I see some places where could go wrong, but mostly that should work. That makes me think that $article->heading is not matching … Read more

Add indexing to meta_value in wp_postmeta

Don’t limit the field, instead, limit the index, e.g. ALTER TABLE wp_postmeta ADD key(meta_value(100)) This limits the index to the first hundred bytes of meta_value. You’ll probably want an index on post_id, meta_key, meta_value for joins. How much of meta_key and meta_value is required depends on your data, for example ALTER TABLE wp_postmeta ADD key(post_id, … Read more

Performance Gains of Relational DB Setup

I can’t comment on foreign keys but moving to InnoDB would be a good idea for large scale. Although it’s a little slower than MyISAM, it does row level locking, rather than table level locking. As a result saving a post or doing a lengthy operation or query won’t lock the posts table, freezing the … Read more

Writing a plugin that notify my friends of new post that mentions(@) them

Twice edited according to kaiser’s suggestions, unsecure version removed. <?php function my_email_friend($post_id = ”) { // get post object $post = get_post($post_id); // get post content $content = $post->post_content; // if @David exists if( 0 !== preg_match(‘/(@\w)/’, $content, $matches) ) $friend_display_name_like=”%” . like_escape($matches[0]) . ‘%’; else return; // do nothing if no matches global $wpdb; … Read more

Inserting dynamic content into a page

As you are building a page template, you can insert in the content of that template whatever you want and use any PHP snippet you want. So, you can continue doing it as you was doing in PHP. For example, this could be your page template: <?php /* Template Name: My template */ get_header(); ?> … Read more

WordPress Connection Pooling

If you just add p: then it conflicts with MySQL Port. So wp-config.php file you should be able to do it by replacing define(‘DB_HOST’,’localhost’); with define(‘DB_HOST’,’p:localhost:3306′);