• Resolved LulaViolet

    (@lulaviolet)


    I got a little challenge here. I’m working on a website for a client, who has no idea about html/php. In some posts of the website will be some data with square meters. Because the client will fill up the posts, its a bit tricky to make wordpress show square meters as square meters and not as for ex. m^2 without using code (m<sup>2</sup>).
    I tried several plugins like wp-Typography and also wp-LaTeX, but the first plugin doens’t work and the second one works but not in the way I would like to.
    Because I’m better in reading php than actually writing it by my self, I was wondering, if it would be possible to create a function in the function.php who automaticly changes the ? m^2 ? into the visual of m<sup>2</sup>.
    Any ideas? Would be very helpfull.

Viewing 5 replies - 1 through 5 (of 5 total)
  • My first thoughts on your suggestion are that it would be (a) difficult and (b) a potential performance issue if you’re effectively parsing the post content all of the time.

    What about creating a shortcode for m<sup>2</sup>?

    Thread Starter LulaViolet

    (@lulaviolet)

    A shortcode is a great idea, its simple and easy for the client, but how do I do that?

    Have you had a look at the Shortcode_API? Once the shortcode is in place, you could them look at adding a button for it to the Visual Editor.

    Thread Starter LulaViolet

    (@lulaviolet)

    Yup it works! Thank you very much for the idea!
    Here is the code I created:

    //[m2]
    function m2_func ($content){
    return "m<sup>2</sup>";
    }
    add_shortcode('m2','m2_func');

    Glad I could help ??

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘m^2 translated as ? square meter ? in function’ is closed to new replies.