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

Execute a function using ajax

<div id=”asinform”> <form id=”productpreview” action=”#”> <input type=”text” id=”asin” name=”asin” value=”” placeholder=”Enter ASIN”/> <input type=”hidden” name=”asin_form_post” value=”1″/> <input type=”submit” value=”Preview”/> </div> <div id=”asinpreview”> <!– Preview goes here –> </div> <script type=”text/javascript”> if ( typeof jq == “undefined” ) var jq = jQuery; jq(document).ready( function() { jq(“#productpreview”).submit(function() { var asin = jq(“#asin”).val(); jq.post( ajaxurl, { action: ‘amazon_product_preview’, … 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