Skip to content

Instantly share code, notes, and snippets.

@mark-obrien
Created February 8, 2016 19:02
Show Gist options
  • Select an option

  • Save mark-obrien/dba0ea5e6ec31cb79480 to your computer and use it in GitHub Desktop.

Select an option

Save mark-obrien/dba0ea5e6ec31cb79480 to your computer and use it in GitHub Desktop.

Revisions

  1. mark-obrien created this gist Feb 8, 2016.
    50 changes: 50 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,50 @@
    <?php

    add_shortcode('nci_careers', 'nci_careers_shortcode');
    function nci_careers_shortcode(){

    $args = ['post_type'=>'careers', 'numberposts'=>-1, 'post_status'=>'publish'];
    $careers = get_posts($args);

    if(! $careers){
    return 'Sorry your are sol';
    }

    $html = '';

    $html .= '<div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">';

    foreach($careers as $career) {

    $html .= '<div class="entry-summary panel panel-default">';
    $html .= '<div class="panel-heading" role="tab"> ';
    $html .= '<h1 class="entry-title panel-title">';
    $html .= '<a data-toggle="collapse" data-parent="#accordion" href="#'. $career->ID. '">'. $career->post_title .'</a></h1>';
    if ( has_post_thumbnail($career->ID) ) {
    $html .= '<div style="width:60px;height:60px;overflow:hidden;float:left;">';
    $html .= get_the_post_thumbnail($career->ID);
    $html .='</div>';
    }
    $html .='<div id="'.($career->ID).'" class="panel-collapse collapse">';
    $html .='<div class="panel-body">';
    $html .='<div class="entry-meta">Posted on <a href="'.get_permalink($career->ID).'">'.get_the_time('F j, Y',$career).'</a></div>';
    $html .='<p>';
    if(strlen($career->post_content)) {
    $html .= $career->post_content;
    }
    else {
    $html .= strip_tags(truncate($career->post_content, 380));
    }
    $html .= '</p>';
    $html .= '</div>';
    $html .= '</div>';
    $html .= '</div>';
    $html .= '</div>';

    }

    $html .= '</div>';

    return $html;

    }