10

Let's say the primary key of the table is my_part_ID. So we will check if there is any primary key value for the combination of user_ID and PL_part_ID as below $my_part_ID = $wpdb->get_var( $wpdb->prepare( "SELECT my_part_ID FROM " . $wpdb->prefix . "pl_my_parts WHERE user_ID = %d AND ...


6

WordPress will not allow you, using its default comment process, to insert empty comments into the database. This is enforced by wp_handle_comment_submission() with the following unconditional code: if ( '' == $comment_content ) { return new WP_Error( 'require_valid_comment', __( '<strong>ERROR</strong>: please type a comment.' ), 200 ); } ...


5

You can change it using following code, add it in your theme function.php or in plugin. remove_action ( 'wp_head' , 'rel_canonical' ) ; add_action ( 'wp_head' , 'my_rel_canonical' ) ; function my_rel_canonical () { ob_start () ; rel_canonical () ; $rel_content = ob_get_contents () ; ob_end_clean () ; echo str_replace ( "https:" , "http:...


4

There is nothing that prevent duplicates here. When you create the table 'church' is a good idea set a UNIQUE sql index for field email, in this way you can rely on email address to preventing duplicate entries. As a generic PHP good practice, you should check the existence of a a variable before using it, using isset function: /* If $_POST['email'] is ...


4

Try to use the following SQL query to fetch duplicate posts: SELECT p2.* FROM wp_posts AS p1 LEFT JOIN wp_posts AS p2 ON p1.post_content = p2.post_content AND p2.ID < p1.ID AND p1.post_type = p2.post_type AND p1.post_status = p2.post_status WHERE p1.post_type = 'post' AND p2.ID IS NOT NULL


4

Just create your database table with a UNIQUE index (or indexes) to prevent duplicates, see MySQL: CREATE INDEX Syntax for starters. For the WordPress specifics take a look at Codex: Creating Tables with Plugins - Create Database Tables. Below example code is taken from there: global $wpdb; $sql = "CREATE TABLE $table_name ( id mediumint(9) NOT NULL ...


3

Don't run a new query for your CPT at every iteration of the main Loop. Pull it once, outside the Look with 'posts_per_page' => 4 then increment it as you go. In other words: $counter = 1; $loop = new WP_Query( array( 'post_type' => 'post', 'posts_per_page' => 20 ) ); $inner_query = new WP_Query( array( 'post_type' => '...


3

The core of the problem is that you set cookies when the content is being accessed, not when it is read. Browsers can try to prefetch content, and your description sound like the browser is prefecthing the "next" link found in the header. From experience, you should avoid setting cookies on the server and prefer setting them on client side (add to the html ...


3

I have found the best way to check it a record exists or not with WPDB is to check using the WPDB update function first. An example of this could be: if(!$wpdb->update($wpdb->prefix.'table_name',$data,array('id'=>$dbRowId),array('%s'),array('%d'))){ $wpdb->insert($wpdb->prefix.'table_name',$data,array('%s')); return $wpdb-&...


3

combining the two answer on this page, I found this worked. $args = new WP_Query(array( 'post_type' => 'post', 'posts_per_page' => -1 )); $loop = new WP_Query($args); while($loop->have_posts()) { the_post(); $args2 = array( 'order' => 'ASC', 'post_type' => 'attachment', 'post_parent' => $post->ID, '...


3

Looking at your code you are calling the function ghoolo_mango() by using the the wp actoin hook. This is fine but be aware that it will add your post everytime a page loads. The problem is that you are also calling the function ghoolo_mango() within the function itself - i.e. it will keep calling it over and over. To fix the problem, remove the line ...


2

if you want to keep the row with the lowest id value: DELETE n1 FROM table n1, table n2 WHERE n1.id > n2.id AND n1.meta_key = n2.meta_key OR if you want to keep the row with the highest id value: DELETE n1 FROM table n1, table n2 WHERE n1.id < n2.id AND n1.meta_key= n2.meta_key


2

I know its too late for this answer, but can help others, you can use Media Deduper plugin to index and find duplicated image , it is also good enough to link the post to existing image.


2

Well, the short answer is the first item consumes more memory then the second one. One of the reason would be that WordPress hooks uses call_user_func_array() to call al those functions dynamically. And call_user_func_array() actually takes an array as one of its parameter and do a search for a function with this name. So in run time it causes memory and ...


2

It is quite hard to properly answer your question with the amount of context in your question, but I am going to try to use the context from your previous question Having a bit more context here on template, and if I read this correctly, this is on your index.php, I still believe and stand by my point that pre_get_posts is your answer. Tackle this problem ...


2

Your code should look like this to exclude duplicate titles <ul> <?php // Initial counter for displayed posts. $counter = 1; // Initial empty array of displayed titles. $titles = []; $portfolio = new WP_Query([ 'post_status' => 'publish', 'post_type' => 'post', 'cat' => '' . $link1 . '', ...


1

You have code like <a href="89"><img src="https://www.docreit.com/wp-content/uploads/2015/09/ABTthumnail3.jpg"></a></div> If your href doesn't start with a / and isn't a complete URL like https://example.com/, it will be used as a relative URI, and will simply be added after the current URL. Add 89 after https://www.docreit.com/...


1

I went the JavaScript way as @Mark Kaplun suggested and it works. There is no more duplicate. Here's my JS for those interested: jQuery(document).ready(function($) { var name = "readposts="; var decodedCookie = decodeURIComponent(document.cookie); var ca = decodedCookie.split(';'); for (var i = 0; i < ca.length; i++) { var c = ...


1

You don't need a select statement to do this, a DELETE statement can handle finding the records. Make sure to backup your database first, then try the following SQL query. DELETE FROM wp_postmeta WHERE meta_key = 'cb_full_width_post' AND meta_value != 'nosidebar-narrow'


1

You're on a page and if we read through the list of conditionals it should hit this one specifically: elseif( ! ( is_404() ) && ( is_single() ) || ( is_page() ) ) { wp_title( '' ); echo ' - '; } It will also hit the below conditional in the next set: else { bloginfo( 'name' ); } Given page Test Page we should see Page Name - Company ...


1

To ensure your content isn't crawled from the hidden admin DOMAIN you could include something like this in your .htaccess file. RewriteEngine On #Force traffic to production URL RewriteCond %{HTTP_HOST} !xxxx.com$ [NC] RewriteRule (.*) http://www.xxxx.com/guides/%{REQEUST_URI} [R=301,L] There is more than one way to handle this first redirect so your code ...


1

This can be a real pain, I know firsthand. The obvious place (that I sometimes forget) is your Trash folder. If it's not there, I would suggest re-saving permalinks. As a last resort, I'd do what you said... a bunch of searches of the database. One time a plugin had auto-generated a page, and after disabling and deleting the plugin, I found the bad URL in ...


1

The renaming to test1.jpg is not due to any cropping / resizing functions WordPress. This is because you already had a file named test.jpg uploaded, and WordPress does not replace files if one exists in the folder that has the same name. If, for some reason you want it to replace files rather than rename it (not recommended) you can use a plugin like: https:/...


1

Before I start, you have a problem with your meta_query. You should not use relation for a single inner meta_query array relation (string) - The logical relationship between each inner meta_query array when there is more than one. Possible values are 'AND', 'OR'. Do not use with a single inner meta_query array. Your first query seems to be correct and I ...


1

Give a backup from your wp_usermeta table and try it: DELETE FROM `wp_usermeta` WHERE `umeta_id` NOT IN (SELECT * FROM (SELECT MAX(`um`.`umeta_id`) FROM `wp_usermeta` um GROUP BY `um`.`meta_key`, `um`.`meta_value`) x) Use MIN instead of MAX to keep row with the lowest id.


1

Easiest way is to install Quick Page/Post Redirect Plugin. Then you'll just have to create a new page with the Title (and Permalink) country when editing this page you'll then have the possibility to redirect it to the other page.


1

You can try Theme test drive. Here's the plugin description: Theme Test Drive WordPress plugin allows you to safely test drive any theme on your blog as administrator, while visitors still use the default one. It happens completely transparent and they will not even notice you run a different theme for yourself. Best part is you can even ...


1

As far as my understanding you want to make changes in the theme without affecting the main theme so For this purpose the best practice would be creating child theme. So you can edit this child theme and your main theme will be safe. So, you can update the theme safely. Refer to WordpressCodex on creating child theme. Hope this solves the problem.


1

Download Theme files via FTP Export site content via Tools -> Export Set up a development environment Upload Theme files (and any needed Plugins) to the development environment Import site content via Tools -> Import Make changes on the development site Upload updated Theme files from development site to live site Profit (probably)


1

After investigating, I realized that it was left over from some fields that I no longer used so I was able to get rid of them.


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