Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9155839
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:39:56+00:00 2026-06-17T12:39:56+00:00

I want to create a wordpress plugin which will replace the specific line inside

  • 0

I want to create a wordpress plugin which will replace the specific line inside the post body with the function output decalared in the plugin. Hope this make sense to you. I’m new ro wordpress development.

Plugin Code

<?php

function money_conversion_tool(){

echo "<form action='' method='post'><input type='text' name='id'><input type='submit'>   </form>";

}

?>

Post html

<h1>Some text some text some text some text</h1>

 [MONEY_CONVERSION_TOOL]

<h2>SOme text some text some text </h2>

Theme file: content-page.php

<?php
        if(strpos[get_the_content(),"[MONEY_CONVERSION_TOOL]"){
         $contents_part = explode('[MONEY_CONVERSION_TOOL]',get_the_content());
         if(isset($contents_part[0])){ echo $contents_part[0]; }    
         money_conversion_tool();   
         if(isset($contents_part[1])){ echo $contents_part[1]; };   
         } else { the_content(); } } else { the_content(); }

}

?>

I don’t think, what i’m doing with the content-page.php is a perfect way. There Should be a better way to this in the plugin code. Tell me what you will do if you want same find of functionality.

I just found from wordpress codex about filters.

Example: <?php add_filter('the_title', function($title) { return '<b>'. $title. '</b>';}) ?>

can i do same thing with the the_content in the plugin ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T12:39:57+00:00Added an answer on June 17, 2026 at 12:39 pm
    if (strpos(get_the_content(),"[MONEY_CONVERSION_TOOL]")){
       echo str_replace('[MONEY_CONVERSION_TOOL]', money_conversion_tool(), get_the_content());
    else
       the_content();
    

    Or shorter:

    echo (strpos(get_the_content(),"[MONEY_CONVERSION_TOOL]")) ? str_replace('[MONEY_CONVERSION_TOOL]', money_conversion_tool(), get_the_content()) : get_the_content();
    

    In your function, don’t echo, just return.

    <?php 
        function mct_modifyContent($content) {
            if (strpos($content,"[MONEY_CONVERSION_TOOL]"))
               $content = str_replace('[MONEY_CONVERSION_TOOL]', money_conversion_tool(), $content);
    
            return $content;
        };
    
        add_filter('the_content', 'mct_modifyContent') 
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to create a wordpress plugin that can catch POST/GET requests to a
I'm trying to create a plugin in wordpress and want to include a JS
I want create wordpress website into which I want create user management... That means
I am writing a plugin for wordpress and I want to create my own
I'm writing a Wordpress plugin which dynamically creates a string. I want to insert
I want to create a custom wordpress plugin. I want to use backbone.js. I
I want to create a plugin, through that plugin user can publish new post,
I want to create a link for each term in a custom Wordpress taxonomy.
I want to create a new Menu in the admin panel of Wordpress for
I want to create a php page on the website (CMS Wordpress), but I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.