2017-09-19, 15:45:21
(2017-09-12, 03:58:36)Carlos Wrote: Create a new template file (e.g. template-blog-single.php) with this contents:
PHP Code:<?php if(!defined('IN_GS')){ die('you cannot load this page directly.'); }
function custom_include_template($temp) {
global $TEMPLATE;
$file = GSTHEMESPATH.$TEMPLATE.'/'.$temp;
if (file_exists($file)) include $file;
}
if (nm_post_has_tag('text')) {
custom_include_template('template-blog-post-text.php');
} elseif (nm_post_has_tag('image')) {
custom_include_template('template-blog-post-image.php');
} else {
custom_include_template('template-blog-post.php');
}
// end
Now in NM Custom Settings, select it with:
Code:single templateFile template-blog-single.php
PS I suggest you use the .inc.php extension instead of just .php for these "special templates" so that they cannot be selected for normal pages by your users.
Thanks Carlos !!!!! That worked a treat. It's allowed me to a) use different header images, fonts etc .. for different kinds of posts, but more importantly I no longer need to run media based js (say for the audio player) on simple text posts.
You can see it in action here:
Main Blog (Directory)
http://www.giantpygmy.net/gptxt/index.php
Image Post
http://www.giantpygmy.net/gptxt/?post=im...ry-beacons
Text Post
http://www.giantpygmy.net/gptxt/?post=i-dont-know-why
Thanks again! It's made a big difference.
C.