Jump to content

Wordpress - Replacing Text from a post.


egiblock

Recommended Posts

I've created the initial page, and got it to show up in the main plugin list, and can activate and deactivate it.

 

Then I have a page with the code {GOLFSCORE} as the content of the page, and that's the only thing that shows when you click on that specific page (as it should).

 

The code is supposed to replace the {GOLFSCORE} with my programming (in this code, it's the old 'Hello World').  But my code isn't doing anything and i can't see what's wrong with it.

 

add_action('init','scoring_insert');

// Function to deal with loading the Golf Scoring Code into pages
function scoring_insert($content)
{
  if (preg_match('{GOLFSCORE}',$content))
    {
      $golf_output = GolfScoringSystem();
      $content = str_replace('{GOLFSCORE}',$golf_output,$content);
}
  return $content;
}

function GolfScoringSystem()
{
$golf_body .= 'Hello World';
return $golf_body;
}

 

 

Link to comment
https://forums.phpfreaks.com/topic/211324-wordpress-replacing-text-from-a-post/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.