WP backend, Show only own comments (give to users who wrote/published/assigned) posts

Using the comments_pre_query filter, this seemed to work well in development and testing: /** * @param null $comment_data Return an array of comment data to short-circuit WP’s comment query. * @param WP_Comment_Query $query WP_Comment_Query instance, passed by reference. */ add_filter( ‘comments_pre_query’, static function ( $comment_data, $query ) { // Limit to admin area. if ( … Read more

Function wpdb::prepare was called incorrectly. The query argument of wpdb::prepare() must have a placeholder

There are 2 places that could have issues: Your first wpdb::prepare() here: // Prepare and execute the count query $count_query = $wpdb->prepare( $count_sql, …$query_params ); The initial value you set for $count_sql is “SELECT COUNT(*) FROM $table_name WHERE 1=1”, and if $filters doesn’t have any key matching your switch, the value of $count_sql will remain … Read more

Split titles by the ” – ” in WordPress

i’ve already solved it, i had to change the $title = get_the_title(); to $title = get_post()->post_title; in the end it looks like that: <?php $title = get_post()->post_title; // Get the title string $parts = explode(‘ – ‘, str_replace(‘–’, ‘-‘, $title)); // Replace em dash with en dash and split the title $artist = trim($parts[0]); // … Read more

install Segment on WordPress

add that code to a js in your theme folder (or child theme if you’re using it). for this example I named the script “analytics.js” and put it in a directory called “js” in my child theme folder. Now register and enqueue the file by placing this code in your functions.php function wpse_load_script() { // … Read more

Send An Email to Admin on User Profile Completion

Based on your question, you could simply call the WordPress function wp_mail( $to, $subject, $message, $headers ); when your var $user_progress[‘completion_percentage’] equal 100 %. <?php if( $user_progress[‘completion_percentage’] === 100 ) { // Complete your variables with original code $to = “[email protected]”; $subject = __(“New user registration”, “yourdomain”); $headers = array(‘Content-Type: text/html; charset=UTF-8’); $message = “A … Read more

File not found.