Tag Info

New answers tagged

1

Fatal error: Cannot redeclare append() is very simple to fix: Your plugin seems to have a function called append(), right? On the wordpress install with this error there is another plugin which has a function append() too. You can fix this using PHP Namespaces or just give your function a more unique name like pluginname_append().


4

First of all, the prefix is only a configuration option and not a security feature. The reason is that once an attacker has access to your database, he can find out any exisiting table prefix within seconds. There's no way this obscurity protects you from any attack. For the prefix itself, WordPress asks you to use only digits, letters (here only basic ...


1

Quite a few options you have here but the simplest I suppose would be to change your SQL query like so: SELECT 0 AS id, user_login AS name, display_name AS tag, user_status AS status FROM wp_users; You can see that now we have the needed order and when you will do the $row['id'] = $i; assignment we will use that position instead of creating a ...


0

There is no post_name argument for WP_Query, if you're querying by slug, it's just name. Without that argument, your query just gets the latest post back.


0

1) In order to check what kind of prefix used by current installantion you can goto wp-config.php in a root directory and find line with $table_prefix = 'PREFIX_HERE'; variable 2) Backup the DB before making any action! 3) Additionally check if other tables with different prefixes/name_patters are not used by badly-written 3rd party plugins. They may not ...


0

There is a plugin that regenerates the urls for post/pages/attachments! You can also go to permalinks and select 'default' or custom structure using post id. This hack is only for pages/post not attachments.


0

Here is one approach: $myrows = $wpdb->get_results( "SELECT first_name, surname, role, email, country, bio FROM members" ); foreach ( $myrows as $row ) { $first_name = $row->first_name; if ( ! empty( $row->bio ) ) { $first_name = '<a href="#">' . $first_name . '</a><div class="bio" style="display: none;">' . ...


0

WordPress does not support MySQL 4 : To run WordPress your host just needs a couple of things: MySQL version 5.0 or greater (recommended: MySQL 5.5 or greater) https://wordpress.org/about/requirements/ While the utf8mb4 encoding is recent change and you might work around it, overall you still need compatible MySQL version.


-2

simply open your exported database in a text editor and replace all utf8mb4 with utf8 and export after. just be critical to choose the right character set when exporting databases.


0

@Adrian, You don't really need to assign anything to variables. You already have the information, you just need to loop through it and add the required HTML as you wish. If you actually want to use a table you can do something similar to: <table> <?php $myrows = $wpdb->get_results( "SELECT first_name, surname FROM members" ); foreach ( ...


1

It depends on what version of WordPress your sites run. If you are up to date, you shouldn't have much of an issue. According to the official WordPress hosting guide, any version of MySQL version 5.0.15 or greater is supported for WordPress. You can give this article a read and see if there is anything that jumps out at you as being particularly ...


0

Some things to check: Have you update the site URL in the wp_options table? Once you log-in to wp-admin change the permalink structure and click save - this makes the system refresh all the links. I personally always use MySQL Workbench to Export and Import data for MySQL databases as it makes life much easier.


1

There may not be a need for a custom query, but I'd recommend it rather than hitting the database: - once for the WP_Query - once more for each post entry And then manually working out the math in PHP. Do it all at once with one MySQL statement. select sum(PM.meta_value) from wp_postmeta PM join wp_posts P on P.ID = PM.post_id where P.post_type='page' ...


2

Try this, should get you started.. (not tested though) function count_total_vote() { $args = array( 'post_type' => 'post', // Your post type 'status' => 'publish', 'meta_key' => 'vote', // Meta Key ); $total = 0; $votes = new WP_Query( $args ); if ( $votes->have_posts() ) { while ( ...


0

$sql = "SELECT p1.*, wm2.meta_value FROM wp_posts p1 JOIN wp_icl_translations t ON p1.ID = t.element_id LEFT JOIN wp_postmeta wm1 ON ( wm1.post_id = p1.ID AND wm1.meta_value IS NOT NULL AND wm1.meta_key = ...


1

Alleluia... After multiple trials (like converting my tables to utf8_unicode_ci -- didnt work), here's the only successful fix I found : define('DB_CHARSET', 'utf8'); In wp-config.php, replace utf8mb4 by utf8.



Top 50 recent answers are included