Tag Info

Hot answers tagged

10

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 ...


3

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 ...


3

Your dot and quote notation is funky. Try this: if($wpdb->get_var("SHOW TABLES LIKE '$table_name'" ) != $table_name){ $sql= "CREATE TABLE $table_name ( id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY, firstname VARCHAR(30) NOT NULL, lastname VARCHAR(30) NOT NULL, email VARCHAR(50), reg_date ...


2

Try this code. Create a file like "my_db.php" and paste this code: global $table_version; $table_version = "1.0"; function func_table_contactus(){ creat_table_contactus(); } function creat_table_contactus(){ global $wpdb; global $table_version; $table_contactus = $wpdb->prefix."contactus"; $slider_ver = ...


2

CSS is the answer. If you look at the HTML code of each row (<tr>), you will see that it has classes that include post ID, post status, post tags, categories, and so on. So, you can easily apply CSS rules based on that classes and based on post tags. For example, this is a row in one of my site: <tr id="post-24392" class="post-24392 type-post ...


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

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

Try edit Privileges for your wordpress database user from phpMyAdmin.


1

WordPress already has both user and post meta data tables, and associated API for handling the data. Storing an array of post IDs for each user in user meta sounds like it would work for your application.


1

I'm not sure if suggesting plugins here is still taboo, but I'm going to go that route for you, because it's going to be the most effective and simple method for you to achieve this. Install two plugins: Custom Post Type UI, and Advanced Custom Fields Alternatively, forego CPTUI (it's just nice to have a visual) and create a new custom post type via your ...


1

This is possible with a custom plugin, but lot of effort. I like the way about css in the front end. The table button in TinyMCE creates a default table, without classes, like: <table> <tr> <td>Text</td> <td>Text</td> <td>Text</td> </tr> <tr> ...


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_'; // ...


1

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 ...


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

Most of the complex tables in admin are produced using WP_List_Table class. Despite being formally private, it has been widely used by third party extensions for years now. It's not exactly friendly to work with, so you should research it and consider if your requirements merit reusing it or just replicating markup to achieve same visual look.


1

As already pointed out in comments gb_bypass_filter is not a valid parameter for WP_Query. If you want to suppress to effect of filters on your query, add 'suppress_filters' => true to your query arguments previous_posts_link() does not accept two arguments, only one. Unlike next_posts_link(), it does not have the second $max_pages parameter. So you can ...


1

...there's no way to include the style in Wordpress posts, at all? You need to add the style tag to the list of allowed post tags, and also ensure TinyMCE recognises it in the editor: function wpse_180472_wp_kses_allowed_html( $tags, $context ) { if ( $context === 'post' ) $tags['style'] = array(); return $tags; } add_filter( ...



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