How to display before H1 Title

Try to use filter like add_filter(‘the_title’, ‘new_title’, 10, 2); function new_title($title, $id) { if(‘your-post-type’ == get_post_type($id)) $title=”Add your DIV block here”; $title .= $title; return $title; }

How to use the password_reset hook to validate new password and display error

You can try using hook the validate_password_reset to validate password. Following code can be used to validate alphanumeric password. add_action(‘validate_password_reset’,’wdm_validate_password_reset’,10,2); function wdm_validate_password_reset( $errors, $user) { $exp = ‘/^(?=.*\d)((?=.*[a-z])|(?=.*[A-Z])).{6,32}$/’; if(strlen($_POST[‘pass1’])<6 || !preg_match($exp, $_POST[‘pass1’]) ) $errors->add( ‘error’, ‘Password must be alphanumeric and contain minimum 6 characters.’,”); }

How do I change TinyMCE button “i” to create a i tag rather than em? [duplicate]

Here’s a simple function that will replace <em> with <i> on your post/page: function replace_em_with_i($content) { $content = str_replace(‘<em>’, ‘<i>’, $content); $content = str_replace(‘</em>’, ‘</i>’, $content); return $content; } add_filter(‘the_content’, ‘replace_em_with_i’); Warning: I have tested the code to check if it works (and it does work), but you might want to do some serious testing … Read more

How can I add new attributes in a Class when my addon is active?

You need to declare a location for this data in your class, like an array beforehand and then use it like below: class test { private $first_name; private $data = array(); public function __set($name, $value) { $this->data[$name] = $value; } public function __get($name) { if (array_key_exists($name, $this->data)) return $this->data[$name]; else return ‘not found’; } } … Read more

$GLOBALS & global doesn’t work [closed]

In my opinion you shouldn’t use $GLOBALS at all. add_filter shouldn’t be used the way you are using it. So there is apply_filter in wordpress that returns a filtered value such that $my_variable = apply_filter(‘my_filter_tag’, ‘default_value’, $arg1); In the above code ‘default_value’ can be anything. $my_variable will hold the value ‘default_value’ if no one called … Read more

admin_post hook not working

You’re missing a ‘ in your code and your function name is different. function my_maybe_add_redirect( $entry, $form ) { wp_redirect( ‘https://www.google.com/’, 301 ); exit(); } add_action( ‘admin_post_submit_images’, ‘my_maybe_add_redirect’, 10, 2 );

The acction hook stop working if i move it from plugin file to theme’s functions.php file

Think about what you’ve written: The acction hook stop working if i move it from plugin file to theme’s functions.php file And: bp_includes is buddypress action and hooked on plugins_loaded The problem is that the code stops working when you move the code to functions.php, which is a theme file. The theme loads after plugins … Read more