Hot answers tagged

11

It's not mandatory per se, but you should always use that and should consider it as mandatory. Consider the scenario when two Wordpress site has been setup in the same database. One with prefix wp_ and another with wp2_. If you install your plugin in both of the sites with the prefix, you created database will be wp_liveshoutbox for first site and ...


4

Consider the following: Your plugin is used on a wordpress network, which uses different table prefixes for each site. Your plugin could be running simultaneously on 836 different sites, all in the same database. wp_385677_liveshoutbox is a perfectly reasonable table name. Your plugin is installed by a user who has some concept of security, and has changed ...


4

You've just discovered an important feature of the core test suite: it forces any tables created during the test to be temporary tables. If you look in the WP_UnitTestCase::setUp() method you'll see that it calls a method called start_transaction(). That start_transaction() method starts a MySQL database transaction: function start_transaction() { ...


3

You pretty much answered it - legacy code. WordPress is the result of years of code evolution, refactoring and (most importantly) multiple developers/coders/authors - whilst they're getting pretty good at enforcing coding standards/consistency, there will always be a trail of the past.


3

There is error in sql query. You have defined time as datetime and default value mentioned in current_timestamp. Define time as timestamp. Also specify length of email and page fields. Corrected query: $sql = "CREATE TABLE " . $table_name . " ( id INT NOT NULL AUTO_INCREMENT, time TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL, //Change datetime to ...


2

When I started out with Wordpress I was anti-plugin. I wanted to add everything in my theme's functions.php. When I looked at the bigger picture it began making sense having and leaving some functionalities inside a plugin. There are many write-ups on the subject of what should go into a plugin and what should go into a theme. I, for one, have done one or ...


2

You can use the function get_post_types to get information on any and all post types that are active at that time. To get info on a specific post type, use get_post_type_object.


1

Try edit Privileges for your wordpress database user from phpMyAdmin.


1

When we call get_the_title(), then the post title is taken through the wptexturize() function via the the_title filter: add_filter( 'the_title', 'wptexturize' ); The en-dash and em-dash are replaced with /* translators: en dash */ $en_dash = _x( '–', 'en dash' ); /* translators: em dash */ $em_dash = _x( '—', 'em dash' ); A simple ...


1

Heyaa..., I've found a final answer, hufft... Yeah, first I include the necessary classes just like in this thread : Fatal error after 4.4 upgrade class-wp-list-table And second, I added up this line in the display_tablenav method in WP_List_Table class : $this->screen = get_current_screen(); before this line : $this->pagination( $which ); ...


1

<?php $mydb = new wpdb('uid','passwd','database','localhost'); $mydb->show_errors(); $query = "SELECT DATE_FORMAT(col1, '%d-%b') AS Pdate, DATE_FORMAT(col1, '%Y') AS Pyear, col2, col3, col4, col5 AS fname FROM table ORDER BY col1 DESC LIMIT 50"; $result = $mydb->get_results($query); echo $mydb->num_rows . ' in table '; ?>


1

I didn't do this recently but in 2014, in a few WordPress projects that I need additional tables I used Laravel components. In WordPress, if you want to create your own tables by using wpdb and mysql queries. But with the Laravel database classes I managed to do this much more elegantly. A quick rundown how I do this: (note: At the time, I used Laravel 4 ...


1

can I just create one using PHPMYADMIN ? Yes.You can. And its a shortest way to do it.


1

First of all you are trying to combine both of the tables by post_parent. $wpdb->posts.post_parent = $wpdb->ftcalendar_events.post_parent I guess data in the ftcalendar_events has children of posts table, try $wpdb->posts.ID = $wpdb->ftcalendar_events.post_parent Also you can try joining tables: SELECT * FROM $wpdb->posts JOIN ...


1

You can use these filters: add_filter( 'request', 'users_orderby_column' ); function users_orderby_column( $vars ) { // Your code goes here }


1

WordPress default comes with some sample post types like pages, posts etc. Wordpress has given option to create our own custom post types also. Both default & custom posts are stored in single table "wp_posts" by differentiating all posts types based on "post_type" column in "wp_posts" table. Eg: pages--> post_type="page", testiminials--> ...


1

Had a similar issue to you. Your problem is the ad_trigger field is a TEXT field. You need to make this a VARCHAR to allow for indexing. TEXT types are not stored in the table. Instead a pointer is stored in the table and the data is stored elsewhere. While you can create an index for them, I think this process would be too complicated for use with ...


1

Users created in Site_A have roles assigned to them. Same users are available in Site_B but they have no roles assigned. Create a PHP script sync-admins.php with the following code in it: <?php // load WordPress environment require( 'wp-load.php' ); // REPLACE 'siteb_' with table prefix of Site_B in line below! $tblPrefixOfSite_B = 'siteb_'; // ...



Only top voted, non community-wiki answers of a minimum length are eligible