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

php code crashes site – possible syntax error

It’s hard to debug only seeing a portion of your code. For starters, you’ve got two <?php opening tags at the top which would certainly cause an error. But I think that’s leftover from your copy and paste. Look at your php server log which will tell you what file and line number the error … 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

Setting Up PHP Workflow in WordPress

Having a local environment that is the same for all devs is pretty easy to setup using vccw.cc or basic-wordpress-vagrant. Use Git for plugins and themes — each as their own repo. Free private repos are available on Bitbucket. Pass your DB around using WP-CLI or wordmove to sync settings and content.