Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #5450

    I’m using wordpress to build a whole load of documentation, and I’m building all the pages in HTML locally, then copying and pasting the body content to the WP editor, each time I make a change.

    I just realised today that actually, I could just upload the original HTML files to a folder somewhere on the server, then use a template to pull in the right content.

    In the TwentyTen theme I see:

    content-gallery.php
    content-aside.php
    etc

    Is this possible within Broadscope’s architecture?

    The other option I just thought of now would be to write a shortcode function and format it so it pulls in my content like so:

    [include file="path/to/file.html"]

    Advice (or alternate ideas) would be much appreciated!

    Many thanks,

    Dave

    #50336

    Hey,

    you can use the get_template_part function: http://codex.wordpress.org/Function_Reference/get_template_part to pull certain templates. I can imagine several ways to use this function with dynamic variables. I.e. you can hardcode the path to the templates and set the template names with post meta values, a shortcode or you could add your own post meta selection field. Kriesi uses this function extebsively – i.e, in single.php he calls the post content with:

    get_template_part( 'includes/loop', 'index' );

    and uses the same template for blogs, archives, etc.

    #50337

    Ah, sweet. I like how the TwentyTen theme has the dropdown built in.

    In the end I went with the shortcode idea. It works great, and I can edit it directly in the WP editor:

    function shortcode_include($atts)
    {
    // variables
    $file = WP_CONTENT_DIR . "/documentation/assets/html/complete/" . $atts['file'];
    if(! preg_match('%.html$%', $file))
    {
    $file = $file . '.html';
    }

    // load file
    if(file_exists($file))
    {
    $html = file_get_contents($file);
    if (preg_match('%<body.+>([sS]+)</body>%', $html, $matches))
    {
    return $matches[1];
    }
    else
    {
    return "Could not determine body tag in '$file'.";
    }
    }
    else
    {
    return "The file '$file' does not exist.";
    }
    }

    add_shortcode('include', 'shortcode_include');

    ?>

    Example code:

    [include file="collections"]

    Thanks for your input though!

    Cheers,

    Dave

    #50338

    You can create your own post meta elements by modyfing broadscopeincludesadmin_option_pagesmetabox.php or you can try to modify this plugin: http://wordpress.org/extend/plugins/custom-post-template/ if you need an ui solution :)

    But your shortcode seems to be a straight forward (and maybe the most flexible) solution.

    #50339

    That is good info!

    These really are great themes. Well done guys!

    #50340

    Glad that I could help you :)

    #50341

    I don’t want my portfolio items to have the same date/comments area as my blog posts. How would I strip this from displaying on the portfolio items? Is this possible? Any help is appreciated.

    #50342

    You can try to replace following code in includes/loop-index.php:

    <div class="blog-meta one_fifth">

    <span class='post-date-comment-container'>
    <span class='date-container'><?php the_time('d') ?><strong><?php the_time('M') ?></strong><?php the_time('Y') ?></span>
    <span class='comment-container'><?php comments_popup_link("<strong>0</strong> ".__('Comments','avia_framework'), "<strong>1</strong> ".__('Comment' ,'avia_framework'),
    "<strong>%</strong> ".__('Comments','avia_framework'),'comments-link',
    "<strong></strong> ".__('Comments<br/>Off','avia_framework')
    ); ?>
    </span>

    </span>

    <?php

    $cats = get_the_category();
    if(!empty($cats))
    {
    echo '<span class="blog-categories">';
    echo '<strong>Categories:</strong>';
    the_category(', ');
    echo '</span>';
    }

    if(has_tag())
    {
    echo '<span class="blog-tags">';
    the_tags('<strong>'.__('Tags: ','avia_frameworkt').'</strong>');
    echo '</span>';
    }
    ?>

    </div><!--end meta info-->

    with:

    <?php if (get_post_type() != "portfolio"){ ?>

    <div class="blog-meta one_fifth">

    <span class='post-date-comment-container'>
    <span class='date-container'><?php the_time('d') ?><strong><?php the_time('M') ?></strong><?php the_time('Y') ?></span>
    <span class='comment-container'><?php comments_popup_link("<strong>0</strong> ".__('Comments','avia_framework'), "<strong>1</strong> ".__('Comment' ,'avia_framework'),
    "<strong>%</strong> ".__('Comments','avia_framework'),'comments-link',
    "<strong></strong> ".__('Comments<br/>Off','avia_framework')
    ); ?>
    </span>

    </span>

    <?php

    $cats = get_the_category();
    if(!empty($cats))
    {
    echo '<span class="blog-categories">';
    echo '<strong>Categories:</strong>';
    the_category(', ');
    echo '</span>';
    }

    if(has_tag())
    {
    echo '<span class="blog-tags">';
    the_tags('<strong>'.__('Tags: ','avia_frameworkt').'</strong>');
    echo '</span>';
    }
    ?>

    </div><!--end meta info-->
    <?php } ?>

    #50343

    I’m having trouble displaying a different archive template for a custom post type.

    I have a custom post type called “treatment” and I want to setup a different archive template for this that doesn’t show the date.

    The custom post type slug is:

    treatment

    The taxonomy slug is:

    treatment-types

    I’m using a child theme and I tried duplicating the normal archive.php file from the main theme, renaming it to archive-treatment and then

    changing line 27 to:

    get_template_part( 'includes/loop', 'archive-treatment' );

    I’ve then created the loop-archive-treatment.php file in the includes folder and removed the date and time from that.

    This doesn’t seem to have any effect though.

    What am I doing wrong? The same prinicple seems to work for template files so I’m not sure what’s special about archives….

    #50344

    I think the reason is that archive templates allow slug or ID extensions for CATEGORIES only: http://codex.wordpress.org/Category_Templates

    In your case WP would use the template if a category slug is “treatment-types” but you’re trying to use the template with a post type slug. Not sure what’s the best workaround but I can give you a hint: I’d use the get_pst_type function: http://codex.wordpress.org/Function_Reference/get_post_type in combination with “if” & “break” to load a different loop template.

    #50345

    Thanks dude – I did actually try the same thing with the category slug too i.e. archive-treatment-types and that didn’t work either.

    I’ll check out your link on the codex

Viewing 11 posts - 1 through 11 (of 11 total)

The topic ‘Is it possible to use custom post templates in Broadscope?’ is closed to new replies.