• I’m very new to WordPress but expert in PHP.

    We would like to have a file that has some strings that we can then use within Pages. I’ve added

    define(‘BCM_NAME’,’ABC Company’);

    to the wp-config.php at the bottom and can’t figure out how to get it to show in the Pages.

    Within a page using the visual editor I’ve tried to add:

    BCM_NAME
    ${BCM_NAME}
    <?php echo BCM_NAME; ?>

    even as a long shot I tried

    [php echo BCM_NAME]

    and all other things I can think of.

    Surely there is a simple way to do this right?

    By the way, these strings don’t have to be in PHP, it could easily be an XML file or something, just as long as I can make a key/pair and use the key in the Pages. Since those key/pairs change but the Page text doesn’t (it’s only things like company names, email, address, phone, etc.) We have hundreds of pages where we want to re-brand them and editing every page for every brand is very time consuming.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Sorry but using global variables just isn’t the way in which WordPress works. Why not turn this predefined texts into functions and call them into templates that way?

    Thread Starter DAE51D

    (@dae51d)

    Because that’s a painful way to just substitute text. I’m shocked this is so cumbersome. Variable substitution seems a pretty common thing to do.

    I’ve been searching plugins and see there are eleventy bajillion of them. What is THE best text replacement one?

    This one looks promising as I could just define the strings like:

    :BCM_NAME: => ABC Company

    In theory this should work I hope…

    Another more PHP-esque way might be with this one.

    Variable substitution seems a pretty common thing to do.

    Not within the WordPress theming system. Is this all for one site?

    Thread Starter DAE51D

    (@dae51d)

    Yes. We sell a service where we set up a machine for customers that use it. We use WordPress for the front end and Magento for the marketplace. We clone this VM for each partner that buys the package. We need to customize their install (or re-brand if you will).

    It is cumbersome to go through all pages and swap out our (default) company name (place-holder) for their company name.

    The above plugin will now allow us to use “:BCM_NAME:”, “:BCM_URL:” etc in the page content and edit one single place to make the changes reflect across the site.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How to use some global defined strings in pages’ is closed to new replies.