Filter to add content to post (2 posts)

  1. Frank San
    Posted 4 years ago #

    I trying to code a plugin for add content to the_content.

    I code this:

    .....if(is_home()) {
            foreach ($rows as $row) {
                  $exitxml.=$row->post_content."<br />";
          	      $content = print_r($exitxml);
    	 return $content;
    add_filter ('the_content', 'publicaratom');

    This code filter every post, but i need filter only the_content of the last post i publishing, because i pass diferent data for each post from meta_box.

  2. Tara
    Volunteer Moderator
    Posted 4 years ago #

    try something like:

    function mytheme_content_filter( $content ) {
         // Do stuff to $content, which contains the_content()
         // Then return it
         return $content;
    add_filter( 'the_content', 'mytheme_content_filter' );

Topic Closed

This topic has been closed to new replies.

About this Topic