WordPress.org

Ready to get started?Download WordPress

Forums

Montezuma
Adding PHP to display Stats (2 posts)

  1. edent
    Member
    Posted 7 months ago #

    Is there any way to place custom PHP in the templates?

    I'm using the WP Post Stats plugin and I'd like to have each post display as "Post Name - 123 views".

    The plugin suggests I can use:

    <?php if(function_exists('the_views')) { the_views(); } ?>

    But obviously Montezuma doesn't allow anything other than its limited set of PHP in the templates.

    Is there anything I can do to make it work?

  2. CrouchingBruin
    Member
    Posted 7 months ago #

    You are correct, Montezuma doesn't allow anything other than the limited set of PHP in the virtual templates, but you can still create a physical template, which is the traditional way of creating templates. According to the documentation under Appearance > Montezuma Options > Main Templates > About Main Templates:

    Convenience or total control: Edit & add virtual files online or - for full PHP access - create & upload physical template files. Physical templates take precedence over virtual templates

    Montezuma's virtual file system offers convenient online editing and creation of templates. For full access to all PHP functions you can still work the traditional way, e.g. with a child theme, real files, and uploading those files with FTP. If a template is requested by WP, for instance "my-template.php", the virtual "my-template.php" is only used if no real "my-template.php" exists in the main directory of the theme. This applies to both main and sub templates.

    So I would try creating a child theme of Montezuma (it's not that hard), copying the contents of the index.php virtual template and using that to create an index.php file in a text editor (with your mods for WP Post Stats), then uploading that file to the /wp-content/themes/montezuma-child folder on your site. You'll still be able to use the other virtual templates and CSS files, but your physical index.php file should override the virtual one.

    If you have other questions about Montezuma, you can post them in the BytesForAll support forum.

Reply

You must log in to post.

About this Theme

About this Topic