WordPress.org

Ready to get started?Download WordPress

Forums

Can I insert a static variable into multiple WordPress posts (6 posts)

  1. jgono
    Member
    Posted 11 months ago #

    I have a WP blog that compares prices of different products - the problem is that when the price of the product changes, I have to go back and manually edit the 30 or more posts that might refer to that product/price.

    Is it possible to set a static variable e.g. Sony50inchTVprice="$999" and then insert that variable "Sony50inchTVprice" into all my posts (instead of the dollar amount), so that when the price goes down, I can just edit the one variable and have it reflect across all my posts?

  2. Andrew
    Forum Moderator
    Posted 11 months ago #

    Which plugin or theme is providing you with the product functionality?

  3. jgono
    Member
    Posted 11 months ago #

    What do you mean product functionality?

    I am using Thesis as my theme

  4. Andrew
    Forum Moderator
    Posted 11 months ago #

    We're not given access to commercial themes like Thesis, so we can't really help you with DIYthemes. Have you contacted them instead?

  5. jgono
    Member
    Posted 11 months ago #

    I would have thought my query was independent of any theme..

    I just want to know if there is a way I can insert a variable into a post, repeatedly enter the same variable across more posts, and modify it from a central location.

  6. Andrew
    Forum Moderator
    Posted 11 months ago #

    Yes you can pass data around in WordPress and a common way of doing this is by writing a function in functions.php which grabs your data and returns it. Then calling that function in the page.

    You can call the function through PHP, which can't be accessed in the Visual or Text tabs when editing a page or post, or through Shortcode. Shortcode can be made using these instructions: http://codex.wordpress.org/Shortcode_API . Shortcode can be called in the Visual tab when editing a page or post.

Reply

You must log in to post.

About this Topic