Redirect first comment (Thanks for comment) with show Autor name and beginning of the comment

You should be able to do something like this: add_filter( ‘comment_post_redirect’, ‘custom_comments_redirect’, 10, 2 ); function custom_comments_redirect( $location, $comment ) { $comment_id = $comment->comment_ID; $custom_url=”https://example.com/thank-you/?comment=” . $comment_id; return $custom_url; } And on the “Thank you” page, you can get the comment info like this: // Make sure you sanitize the GET input $comment_id = (int) … Read more

How to edit HTML of my website on WordPress? [closed]

The HTML of a WordPress page is a mix of many sources. Parts of it come from plugins, other parts from the main template, others from the database, others from the core. They can also come from widgets, template options, and so on. Unfortunately, WordPress pages are not on specific files that you can open … Read more

How to disable send e-mail notification new comments for some posts

You can use notify_moderator and notify_post_author filters to control whether or not the comment notification should be sent – to the moderator or comment author. add_filter(‘notify_moderator’, ‘prefix_filter_sent_comment_notification’, 10, 2); add_filter(‘notify_post_author’, ‘prefix_filter_sent_comment_notification’, 10, 2); function prefix_filter_sent_comment_notification( bool $maybe_notify, int $comment_ID ) { $comment = get_comment($comment_ID); $comment_post = get_post($comment->comment_post_ID); // determine, if notification should sent or not … Read more

WPML best page selector with php

This code returns the post ID in the current language. $translated_post_id = apply_filters( ‘wpml_object_id’, $post_id, ‘post’ ); So, you can use $translated_post_id in is_page. Documentation.  

How do I populate custom field with current user role in Woocommerce [closed]

wp_get_current_user() returns a user object. You can’t output objects directly. Proceed by getting the users roles like $roles = (array)$user->roles;. Note that this returns an array though, so you will probably want to use the first element with $roles[0]. Your code might look like this (untested): function onboarding_update_fields( $fields = array() ) { $user = … Read more

str_replace with the_content is not working

If you give a look at the documentation, of str_replace you will find your needs. https://www.php.net/manual/en/function.str-replace.php There is 3 choices for you there : function replace_text_wps($text){ $replace = array( ‘https://www.facebook.com/something”>’ => ‘https://www.instagram.com/something”>’, ); $text = str_replace(array_keys($replace), array_values($replace), $text); // OR $text = str_replace(array( ‘https://www.facebook.com/something”>’ ), array( ‘https://www.instagram.com/something”>’ ), $text); // OR $text = str_replace(‘https://www.facebook.com/something”>’, ‘https://www.instagram.com/something”>’, … Read more

Short code template + ajax

As Tom J Nowell noted in the comments, your setup is bit wonky, which is why it won’t work. You need to add the ajax actions and register the shortcode earlier – i.e in a custom plugin or in the theme functions.php. This is related to how WordPress handles requests and in which order it … Read more

How to show childs of certain custom post type in option list?

Try to use wp_dropdown_pages instead of wp_list_pages . This function does almost the same, but returns a dropdown, instead of list items. (do not need to echo select opening and closing tags separately) if ( $post->post_parent ) { $children = wp_dropdown_pages( array( ‘name’ => ‘your-name’ // paste field name here ‘child_of’ => $post->post_parent, ‘post_type’ => … Read more

Use post ID in functions.php file adminside

It depends on, where you are calling these functions. That is the point, where you enter the var into the function. First, remove the global $post from your functions.php! It makes no sense there! In the functions.php you declare the functions, not call them! I assume, you call your function in some template. So the … Read more