Skip to content

Commit

Permalink
add some documentation on shortcode use
Browse files Browse the repository at this point in the history
  • Loading branch information
dannyvankooten committed Feb 26, 2024
1 parent f778f41 commit 893cf5c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
18 changes: 18 additions & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,24 @@ Yes, see [github.com/ibericode/koko-analytics](https://github.com/ibericode/koko
### Where can I find more documentation?
Have a look at the [Koko Analytics knowledge base](https://www.kokoanalytics.com/kb/).

### How to show number of visits to a page?

You can use the `[koko_analytics_counter]` shortcode to show the number of visitors to the current page.

It takes 3 optional arguments:

- `days`: Show count over the last N days. Defaults to "3650".
- `global`: Whether to show the global count (for the entire site) or for the current page only. Defaults to "false".
- `metric`: One of "visitors" or "pageviews". Defaults to "visitors".

Example use with arguments:

`
[koko_analytics_counter days="30" metric="pageviews" global="true"]
`



== Screenshots ==

1. Koko Analytics' dashboard to view your website statistics.
Expand Down
2 changes: 1 addition & 1 deletion src/class-shortcode-site-counter.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function content($args)
);
$args = shortcode_atts($default_args, $args, self::SHORTCODE);

$id = $args['global'] ? 0 : (int) get_the_ID();
$id = $args['global'] && $args['global'] !== 'false' ? 0 : (int) get_the_ID();
$start_date = create_local_datetime("-{$args['days']} days")->format('Y-m-d');
$end_date = create_local_datetime('tomorrow midnight')->format('Y-m-d');

Expand Down

0 comments on commit 893cf5c

Please sign in to comment.