Tag Info

New answers tagged

1

For anyone still interested in customizer export/import functionality, we just released a new plugin on the wordpress.org repo that does exactly that! https://wordpress.org/plugins/customizer-export-import/ Don’t hesitate to let us know what you think!


0

You could do this using the WordPress uninstall.php support: <?php if( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) exit(); global $wpdb; $wpdb->query( "DROP TABLE IF EXISTS NestoNovo" ); delete_option("my_plugin_db_version"); ?> This uninstall.php file is called when your plugin is deleted.


0

Fortunately, this complicated database query is no longer needed. WordPress 4.1 added the ability to make complex nested meta queries which is exactly the thing I was trying to accomplish. Here is the Trac ticket with the feature: https://core.trac.wordpress.org/ticket/29642


0

You can use PHP's fgetcsv() or str_getcsv() function to parse the uploaded CSV file. Your CSV will need to include a column with the Post's ID as well as the columns matching up to your custom field names. Loop through the CSV and for each line update the custom fields for that post using update_post_meta() http://php.net/manual/en/function.fgetcsv.php ...


-1

The right solution is checking the server TIME. If it is wrong SSL doesn't work fine.


1

If you're trying to get all meta values for a key within a specific post type, you can do something like this in a single query: SELECT post_id, meta_value FROM $wpdb->postmeta pm, $wpdb->posts p WHERE meta_key = 'sd_rating' and pm.post_id = p.ID AND p.post_type = 'cpu'


1

I have found a way : global $wpdb,$post; $query_ids = $wpdb->get_results("SELECT ID FROM ".$wpdb->prefix."posts WHERE (post_type = 'cpu') LIMIT 0,10"); foreach ($query_ids as $query_id) { $query = ...


0

I think you can to use a CPT "Meetings" where each post is a meeting, you can handle hundreds or thousands with no problem a Custom Taxonomy "Meetings Type", in this way you can set types for meeting posts. Just like categories for standard posts. a CPT "Attendees" where each post is an attendee. Being posts you can handle hundrends or even thousands of ...


0

Meetings => Custom Post Type Meeting Type => Custom Taxonomy Attendees => Post Meta (array as described) To get all Attendees for a Meeting Type, loop through all Meetings in the Type and for each retrieve Attendees. You can push each Meeting's Attendees into a new array to be sorted if needed, than foreach the array to write out the details.


0

It's an interesting idea you have had and I've done something remotely similar but with companies and employees as a sort of CRM I'm building. What I've done is go down the plugin route and utilised the WP_List_Table class as it organises things very nicely for me. What I'm doing is creating a set of companies, in your case I'd say Individual Meetings, ...


1

Use WP CLI! First grab the posts you want, we'll use the wp post list command, and we need to run the command in our WordPress directory on the server. Here I'm grabbing all posts in October 2014 on my blog: wp post list --year=2014 --monthnum=10 This gives me ( oh noes my secret draft posts ): ...


0

Why don't you directly echo the $num as it will contain the count of rows already...Here's the edited part.. //To show number of rows in table function DB_Tables_Rows() { global $wpdb; $table_name = $wpdb->prefix . 'mydata'; $count_query = "select count(*) from $table_name"; $num = $wpdb->get_var($count_query); echo $num . ...


0

WAY #1 You can use the WordPress way using $wpdb class: <?php global $wpdb; $table_name = $wpdb->prefix . 'mydata'; $my_query = $wpdb->get_results( "SELECT * FROM $table_name" ); echo $wpdb->num_rows; The codex says: Since this function uses the $wpdb->query() function all the class variables are properly set. The results count for a ...


4

This answer is the way I would take to solve the issue if I had to face it, it means is not the answer but one of the possibilities. All the operations I will suggest should be run on a development/local server on a backup of database and not on production nor on original database. If you have 26,000 posts but post id like 4,863,166,253 there are zillions ...


0

You probably don't need a custom table. Read the top answer to this question which recommends using Custom Post Types. As for displaying the data, I'd recommend you investigate Custom Page Templates. Then you can create a page that loads your data however you'd like.


0

I figured out my error in the query, Thank you all guys for responding, I just gave the piece of code <?php global $wpdb; $contactus_table = $wpdb->prefix."contactus"; //error with the query $sql = "INSERT INTO $contactus_table (firstname, lastname, email, query, reg_date) VALUES ('$firstName', '$lastName', '$email', '$query', ...


0

You have to do it yourself. It's just a frame of what it should be at least. Search more and use the format. The following is not checked, so it's your turn... :) <form action="" method="post" enctype="multipart/form-data"> <label for="first-name-text">First name: </label><input type="text" id="first-name-text" name="firstNametxt" ...


1

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


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


3

If your entire page fits in the 4GB LONGTEXT post content field, the limit to the number of pages would be related to the amount of RAM available on your server. When a multipage post is loaded, it is exploded on <!--nextpage--> to put your post into an array of individual pages, so at that point your single page load is consuming at least twice the ...


3

It depends on local factors and actual usage patterns. Bigger queries require more memory to store the data and potentially, depending on the plugins you use, to process it into the response, therefor you are more in a risk of running out of memory. With Bigger response (i.e. bigger page HTML) it takes more time to transfer the page to the browser making the ...


0

For copying a site to a new location. use --add-drop-table during export, if you're importing to an empty database. omit --add-drop-table during export, if you're importing to merge the database. Remember to update wp_options after import each time, since path is different. Also, update the .htaccess file with new path.


2

Persuming "article_datetime" to be a numeric value, I would suggest that instead of using 'orderby' => 'meta_value' use 'orderby' => 'meta_value_num' If still query is slow, than remove: 'orderby' => 'meta_value', 'meta_key' => 'article_datetime', 'order' => 'DESC' and instead sort the result in php.


0

A Google of wordpress wxr pulled up this link as the first result: https://wordpress.org/support/topic/xml-to-wxr-issue which suggests to If you paste the following line into your export file after the Language defining line in the section near the topyou should be good to go: <wp:wxr_version>1.1</wp:wxr_version> But I would strongly ...


0

<?php if (!empty($_GET['msg'])) { global $wpdb; $user_id = (int) $_GET['id']; $sql = $wpdb->prepare("SELECT * FROM wp_quiz WHERE quiz_id='%d'", $user_id); $result = $wpdb->get_row($sql, ARRAY_A); var_dump($user_id); var_dump($result); $total = $result['total_count']; Ended up figuring it out after I posted the ...


2

First off, you should not be handing an untrusted input (in this case, $_GET['id'] to your database. Always SQL-escape the query and validate/sanitize the data. (In the code snippet below, it's SQL-escaped using $wpdb->prepare() for escaping and int typecasting to sanitize to integer value). Secondly, the $wpdb object provides more than just the query() ...


-2

require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); $drzava = "your sql"; dbDelta($drzava);


0

This is technically challenging. WordPress must have access to your DB password in plain text. Having access to wp-config.php contents is already breach of security in progress. There are alternate approaches to configuration, such as loading credentials via environmanet variables, but in practice they are used exceedingly rarely because PHP config file is ...


0

Simple – if you do not want duplicate information then before you insert anything check if such data is already present. Just query for it and see if there is a match. From WP perspective however, you seem to be looking at technique (database table) that you will rarely need in practice. WordPress offers wealth of storage options and your time is likely ...



Top 50 recent answers are included