Why are two functions over-riding each other?

It looks like you are overwriting the comment text with your commentimage_comment_text2 filter, try this to append the ratings text: add_filter( ‘comment_text’, ‘commentimage_comment_text2′ ); function commentimage_comment_text2( $comment ){ $rtt = “<br>Rating”; return $comment.$rtt; } ps: you forgot the $comment input parameter. Here is a poor man’s skematic picture of the filter flow in WordPress 😉 … Read more

Dynamically override page.php or single.php with custom templates using function

One way you can do that is by adding a filter to the hook {$type}_template. Sample code: function my_plugin_custom_template( $template, $type ) { switch ( $type ) { case ‘page’: $template=”/path/to/custom-page-template”; break; case ‘single’: $template=”/path/to/custom-single-template”; break; } return $template; } add_filter( ‘page_template’, ‘my_plugin_custom_template’, 10, 2 ); // Filter for page.php add_filter( ‘single_template’, ‘my_plugin_custom_template’, 10, 2 … Read more

Conflicting save_post functions when passing the post id and saving custom meta boxes for different post types

After doing some more research I found that: Instead of hooking the add_meta_box function into admin_menu it should be hooked into add_meta_boxes Instead of the foreach loop use the update_post_meta function on the save function Instead of using the wp_nonce_field the data can be sanitized using esc_attr and strip_tags To pass the post id to … Read more

One time username change from frontend?

Just add a meta record that tracks the state of the username-changing actions: $user = wp_get_current_user(); $did_one_change = get_user_meta($user->ID, ‘changed_username’, true); if($did_one_change !== false) wp_die(‘You already changed your user name once!’); wp_update_user(array( ‘ID’ => $user->ID, ‘first_name’ => $_POST[‘first_name’], ‘last_name’ => $_POST[‘last_name’], )); // here add a meta entry that suggests the user has changed their … Read more

Why won’t register_setting() create a setting?

I am not exactly sure what you mean by saying that you can see your settings section and fields displayed correctly, but your my_plugin_settings has not been created. I know sometimes I forget to add the actual admin part in which generally looks something like this: settings_fields( ‘my_plugin_settings’ ); do_settings_sections( ‘my_plugin_settings’ ); submit_button(); Or is … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)