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 3791748
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T12:31:01+00:00 2026-05-19T12:31:01+00:00

Hey guys, first off I played around with shortcodes, but they aren’t working. I

  • 0

Hey guys, first off I played around with shortcodes, but they aren’t working. I might have a some conflict (tried for hours to find it) but for now, it’s not an option. But the following works in allowing my commenters to use the [img] tags in their comments (which get replaced to the html equivalents) and I’d like to expand on it.

Please no plugins!

What I’d like to do is amend the following bit of code to allow [b], [i], and [code] (both lower and upper case entries) to spit out the html equivalents so my comments can just use the standard bbcodes when they comment, very much how the current function works:

function embed_images($content) {
    $content = preg_replace('/\[img=?\]*(.*?)(\[\/img)?\]/ei', '"<img src=\"$1\" alt=\"" . basename("$1") . "\" />"', $content);
    return $content;
}

add_filter('comment_text', 'embed_images');

I’ve tried and tried but can’t get it to work. Any coding help would be greatly appreciate. Thanks guys.

Edit: Okay guys, got it working. Does this look okay? I mean it works, but how is the code… decent?

function embed_bold($content) {
    $content = preg_replace('/\[b]*(.*?)(\[\/b)?\]/ei', '"<strong>$1</strong>"', $content);
    return $content;
}

add_filter('comment_text', 'embed_bold');
  • 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-05-19T12:31:02+00:00Added an answer on May 19, 2026 at 12:31 pm

    I once wrote a blog post about using regex for bbcodes. Most recommend using a PHP extension specifically built for BBCodes however. Here is the article:

    http://www.spotlesswebdesign.com/blog.php?id=12

    /\[b](.+?)\[\/b]/i
    

    replace with

    '<strong>$1</strong>'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey guys... I'm working on creating one of my first websites and currently have
Hey guys, first off all sorry, i can't login using my yahoo provider. anyways
Hey guys. I'm not much of a programmer, but still need to do some
Hey guys, this is my first time actually posting at stackflow but i've used
Hey guys, I have a raidan style 2d flying/fighter game that im working on.
Hey guys I need some help with this: I have two view controllers, let's
hey guys having this really simple problem but cant seem to figure out have
Hey guys! I have some problems reloading my tableView. I have subclasses my tableView,
Hey guys hoping for a little help here. First I created a working map
Hey guys, I'm very excited about how experienced I am in programming. The first,

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.