Is this correct usage of filters in WordPress [closed]

Umm. Normally, people ask questions here that are more than yes/no questions, but hey, I’m game. Yes, that code looks fine to me. Hope that helps! 🙂 Also note that there is a built in function called __return_true which is there for usage just like so: add_filter( ‘image_priority’, ‘__return_true’ ); Easy. Also also note that … Read more

Updating User Profile on Registration

Try dumping your data and you should see the problem: function coinDeposit() { $current_user = wp_get_current_user(); var_dump($current_user); die; update_user_meta( $ID, ‘depositAddress’, $account); } The user object is empty. That is because a newly created user is not automatically logged in. There is an email confirmation step, and then login. Until that login, wp_current_user() isn’t going … Read more

wp_get_attachment_link filter not working

Have you tried using the ‘the_content’ filter? Something like this should probably do the Job , note that i have not had the time to test this . function my_prettyadd($content) { global $post; $pattern = “/(<a(?![^>]*?rel=[‘\”]prettyPhoto.*)[^>]*?href=[‘\”][^’\”]+?\.(?:bmp|gif|jpg|jpeg|png)[‘\”][^\>]*)>/i”; $replacement=”$1 rel=”prettyPhoto[“.$post->ID.’]”>’; $content = preg_replace($pattern, $replacement, $content); return $content; } add_filter(“the_content”,”my_prettyadd”); simple regex that will add a rel to … Read more

WordPress URL rewrite problem

My recommendation is to register a custom post type. You can call it products, and then all posts placed under Products will get the http://domain.com/products/some-product rewrite. Once it’s its own post type, you can specify a custom template for it, single-product.php, and you can add any custom fields, classes, etc. from there.

Problem with shortcodes in external file

Shortcodes and Tags At first, please keep in mind that your understanding of tags is actually a shortcode. A Tag is used to add meta information to content, while a shortcode is used for adding functionality, usually to be called from inside the content. To your Problem As @s_ha_dum pointed out, you should implement your … Read more

Save something to global var in add_filter

I ran a test and the following works: global $testMe; $testMe = 0; function my_acf_update_value( $value, $post_id, $field ) { global $testMe; $testMe = $value; return $value; } add_filter(‘acf/update_value/key=field_5308e5e79784b’, ‘my_acf_update_value’, 10, 3); // Test: Apply the filter apply_filters(‘acf/update_value/key=field_5308e5e79784b’,’a’,’b’,’c’); // end Test echo $testMe; // prints ‘a’ So, in principle, your code is functional. There are … Read more

Activate short codes for all post queries?

There is a way to apply that to all post content. function sc_all_content_wpse_137734($posts) { foreach ($posts as &$p) { $p->post_content = do_shortcode($p->post_content); } return $posts; } add_filter(‘the_posts’,’sc_all_content_wpse_137734′); I would suggest that this is a very, very good way to break things. Plugins and themes will not expect shortcodes to be rendered that early, and the … Read more