Creating static page with Simple Graph

Using content tags

As of version 1.0.0, you can now use simple tag to include simple graph(s) in your posts and pages. However, this required WP2.2 or newer. If you’re using earlier versions of Simple Graph or WordPress, scroll down the page for instructions on how to do this manually.

If you want to insert a graph in posts and/or pages, simply write a string similar to following in your post or page.

Graph by www.pasi.fi/simple-graph-wordpress-plugin/

Just replace the values as you wish. The ones above are default values, and if you don’t need to change the default value, you can simply omit that value from the string. I.e. Graph by www.pasi.fi/simple-graph-wordpress-plugin/ alone produces the graph with default values drawn from widget setup.

* n is number of widget options, from where default options (such as colours) are drawn
* x is width, any positive value is acceptable
* y is height, any positive value is acceptable
* trend is whether trend graph is shown, 0 = no, 1 = yes
* wkly is whether weekly averages are shown, 0 = no, 1 = yes
* lm is whether only values from last month are shown, 0 = no, 1 = yes
* ytd is whether only values from last year are shown, 0 = no, 1 = yes
* uid is user ID of the graph owner (see WordPress dashboard -> Users)
* gid is user-specific graph number, same as in widget control panel’s graph# selection

The manual (old) approach

This page documents how my weight watch page was created for those who are not familiar with creating or editing WordPress page templates.

Step 1. Copy page.php to graph.php

Navigate to your theme folder and find a file called page.php. This is a template which specifies how your static pages are displayed. Copy the file to other name, for example graph.php.

Step 2. Edit your graph.php file

In your newly created graph.php file, find the position where the page entry begins. Usually it looks like this: <div class="entrytext">

Replace the contents of that div elements with something similar to the example below. This is the source code excerpt from my own weight watch page.

[html]

All measurements

Weekly averages

Last month

Read the rest of this page »

‘); ?>
Pages: ‘, ‘

‘, ‘number’); ?>

[/html]

Also, don’t forget to change the template name at the beginning of the page template file, for example to “Graph Template”.

Step 3. Create a new static page

In your WordPress dashboard, go to “Write Page.” On the right-hand options column, select “Graph Template” as the Page Template. If you wish, you may enter page content, which will appear below the graph(s). And you’re done!

Leave a Reply

Your email address will not be published. Required fields are marked *