Custom wordpress SQL statement for a website

I think this could be life saver for you . This is a simple function for creating multiple loops. It retrieves a list of latest posts or posts matching criteria. <?php $posts_array = get_posts( $args ); ?> <?php $args = array( ‘numberposts’ => 5, ‘offset’ => 0, ‘category’ => , ‘orderby’ => ‘post_date’, ‘order’ => … Read more

Showing Error(TAble already exist)

Try with this, It will delete existing wp_commentmeta table then create ‘wp_commentmeta’ table : DROP TABLE IF EXISTS `wp_commentmeta`; CREATE TABLE `wp_commentmeta` ( `meta_id` bigint(20) UNSIGNED NOT NULL, `comment_id` bigint(20) UNSIGNED NOT NULL DEFAULT ‘0’, `meta_key` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `meta_value` longtext COLLATE utf8mb4_unicode_ci ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

How to write inner join using posts_clauses?

First, his filter is explained in the manual and is found in the code. If you have questions about hooks and functions, the manual and code is a good place to start looking for answers. The post_clauses hook is passed the associative array to filter, so just manipulate the where and join indices as per … Read more

Adding profile data to database

To show extra fields in profile, use this hook: function myplugin_show_profile_extra_fields( $user ) { // echo your extra fields here } add_action( ‘show_user_profile’, ‘myplugin_show_profile_extra_fields’ ); add_action( ‘edit_user_profile’, ‘myplugin_show_profile_extra_fields’ ); And to save extra fields use following hook: function myplugin_save_profile_extra_fields( $user_id ) { if ( !current_user_can( ‘edit_user’, $user_id ) ) { return false; } update_usermeta( $user_id, … Read more

Theme Options – localhost to new url

The way I’ve always migrated sites is not by search and replacing, but just by changing two fields in wp_options: siteurl and home. Try doing only this, no search and replace, and see if it fixes your options page / widgets. It may be that by replacing all instances of “localhost,” you’re actually impairing your … Read more

Importing Concrete5 content to WordPress

If you go to WordPress’s Tools » Import page in your site’s Admin section (eg, http://example.com/wp-admin), you’ll find that it can import, among other things, HTML pages. So if you have a way to export your Concrete5 site to a directory of HTML pages, you should be able to import them that way.

SQL Database Lost

You should be able to restore the database by simply copying those files into the DB folder. (e.g., /var/lib/mysql/dbname). Typically there is a FRM file included as well.

SQL command to export post_content from wp_posts using phpMyAdmin

Use This Script <?php $servername = “localhost”; $username = YOUR_USER; $password = YOUR_PASSWORD; $dbname = YOUR_DB_NAME; // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die(“Connection failed: ” . $conn->connect_error); } $a1 = ($_GET[‘id’]); $sql = “SELECT post_content FROM `wp_posts` where ID=’$a1′”; $result = $conn->query($sql); if ($result->num_rows > … Read more