Using a $GET parameter from a URL, to redirect to a URL (WordPress)

I suggest researching add_query_arg. You can use it like this: $params_array = array(); foreach($_GET as $key => $param){ $params_array[] = $key . ‘=’ . urlencode($param); } $url = get_permalink(ID) . ‘?’ . implode(‘&’, $params_array); wp_redirect( esc_url_raw( add_query_arg( ‘login’, ’empty’, $url ) ) ); or you can add multiple params like this: $params_array = array(); foreach($_GET … Read more

Which function crops images in wordpress?

The image goes through multiple processes for the thumbnail to be generated. Take a look into the WP_Image_Editor class in the wp-includes/class-wp-image-editor.php. This class handles cropping, resizing, etc. There is a public function inside this class, named crop(). This might be what you are after. However, the actual resizing is handled by the function multi_resize(), … Read more

Run str_replace on title and save the output to a custom field

the_title_rss() outputs its value straight away so it can’t be used in a function like that, you would have to use get_the_title_rss() Or alternatively the_title_rss() has a filter we can hook in to and return your shortened title is possible. (You would add this to your functions.php) function gg_short_title_rss($title) { // This can return false, … Read more

PHP Warning: strip_tags() expects parameter 1 to be string?

If you look at the source of get_the_term_list, you will see that it will try to get the terms first. If that doesn’t succeed, it will return an error or false. So you would have to account for that before you try to strip the tags: if (!is_wp_error ($categories) && false != $categories) $categories = … Read more

How to execute html code inside php?

I wouldn’t recommend writing PHP code in the content this way, e.g. for security reasons. Most likely the shortcode is using eval() and you need a valid PHP code snippet in each such call. The PHP documentation has this warning: Caution The eval() language construct is very dangerous because it allows execution of arbitrary PHP … Read more

How can I include shortcodes within PHP?

In your case do_shortcode should do the trick. If your shortcode is just like [my_shortcode] then try echo do_shortcode( ‘[my_shortcode]’ ); If you have opening and closing then echo do_shortcode( ‘[my_shortcode]Inner text[/my_shortcode]’ );

How to list commenters and days since last commented

It looks like you could add the MAX( comment_date ) last_commented_date to the field list to get the latest date, each user commented. Then use e.g. the human_time_diff() function to get a human readable text for how long ago each user commented. human_time_diff( strtotime( $result->last_commented_date) ) For safety reasons, you should then prepare the SQL … Read more

add onchange to select in a wp form

you can add any attribute to <select> using wordpress filter wp_dropdown_cats . wp_dropdown_cats filter allows you to modify the content of the taxonomy drop-down output. Try below code. function addAttributeToDropdown($html_content){ $html_content = str_replace(‘<select’,'<select onchange=”myFunc()”‘,$html_content); return $html_content; } add_filter(‘wp_dropdown_cats’,’addAttributeToDropdown’); add this inside your functions.php file