0

I'm wondering if it possible to change the automatic place below the_content() function; this is becuase I`m displaying custom information fields, but activating the social plugins which have not it´s own implementation code, the social bar or facebook commnents appears between the content and the custom fields, so important values are below the social content :/

can be created another hook to point the content of plugins? :) probably I have to modify the plugin Simple Facebook Comments

3

The plugin add content using the_content filter with a lower priority: 100.

So you can create a function that output metafields and use same filter with an higher priority, even the standard 20 priority is good.

function my_post_custom_data( $content ) {
  if ( ! is_single() ) return;
  global $post; 
  // here go the code that retrieve and append the custom field to the content
  // following is just an example
  $mydata = '';
  $a_field = get_post_meta($post->ID, 'a_key', true) ? : '';
  $another_field = get_post_meta($post->ID, 'another_key', true) ? : '';
  if ($a_field) $mydata .= '<li>A key: ' . $a_field . '</li>';
  if ($another_field) $mydata .= '<li>Another key: ' . $another_field. '</li>';
  $mydata = ($a_field || $another_field) ?  '<div class="myfields"><ul>' . $mydata . '</ul></div>' : '';
  // don't forget to return, at least, the content...
  return $content . $mydata;
}

add_filter('the_content', 'my_post_custom_data');
  • I tried to implement the code for this lines <br> if (function_exists("insert_audio_player")) { insert_audio_player("[audio:$mp3]");} – Fernando Baltazar Sep 21 '13 at 0:05
  • @g-m I tried to implement the code for this lines <br /> 'code'if (function_exists("insert_audio_player")) { insert_audio_player("[audio:$mp3]");} 'code' following your example and the code of plugin and noticing the priority 100, I changed my own and, :D I got no results, sorry the 5 minutes for edit finished before typing – Fernando Baltazar Sep 21 '13 at 0:13
  • @FernandoBaltazar insert_audio_player is not a WP function. Sorry, but I've not understand what you want to do... In the question you tell only about printing some custom fields and Simple Facebook Comments plugin, nothing about audio player. – gmazzap Sep 21 '13 at 0:44
  • Yes, finally I could show the data above the social plugin, the problem was that the data it was showing above the main content , using the priority 20 :/ ; I have an screen of 15" and I couldn't see the full results. Now i'm showing the player using custom field values :) – Fernando Baltazar Sep 21 '13 at 0:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.