How do I add portfolio boxes...

eCommerce WordPress theme with various e-store features and WooCommerce support.
GK User
Mon Aug 19, 2013 3:17 pm
Hi, I want to add portfolio boxes onto the body of a page/post. Here is an example link of what I'm talking about (Under the heading "conditions I treat"): http://drshawnadarou.com/womenshealth/e ... etabolism/

The way it works in the template is that in the WP control panel a new section "Portfolio" shows up under "Posts" (not sure which plugin it is). Under it, choose "Add New Item". Populate it with content. Then you add the portfolio boxes to a page/post using a shortcode.

Example shortcode:

[portfolio_posts title="Children's Health Conditions" limit="10" orderby="date" order="DESC" cats="child" columns="3" carousel_mode="no" slideshow="false" border_top="no" border_bottom="no"]

Any ideas on how I can add this feature this template. thanks so much.

J.
User avatar
Gold Boarder

GK User
Mon Aug 19, 2013 7:29 pm
Its a lot of custom work.
You would need to create custom post types support and shortcode support.
With moderate php and WordPress Codex knowledge You could copy needed code from the other template, or just create a plugin basing on that code.
User avatar
Moderator

GK User
Mon Aug 19, 2013 8:55 pm
Thanks so much. That is exactly what I discovered too. I would like to copy that CPT and apply it to this theme but I'm not sure I can do this without messing things up. The author of that CPT put many of the CPT files in a separate directory call "lib" in the themes folder. He then used -> require_once PARENT_DIR . '/lib/post-types.php'; in the functions.php file to refer to those files.

centindu_grab2.gif


additional files were also added that refer to the CPT
User avatar
Gold Boarder

GK User
Mon Aug 19, 2013 8:59 pm
here r the extra files...

centindu_grab3.gif



Would it be easier to copy the files/code to this them or just create a new CPT??

Could anyone recommend a good CPT creator plugin which has can be format posts in rows and columns, etc??
User avatar
Gold Boarder

GK User
Wed Aug 21, 2013 3:59 pm
I don't have the link to the site, but I'm 200% sure, that there are sites with "generators" that helps to generate needed code.
Adding CPM is quite simple and can be "generated". Then You could load it as additional library to our template, or just place in newly created plugin.
Its same with adding custom taxonomies for that CPT.
Ill post You some code that might be helpfull - You can always look for informations in wordpress codex etc.

Creating CPT:
Code: Select all
//add tweet custom post type
add_action( 'init', 'cs_twitter_register_post_types' );
function cs_twitter_register_post_types() {
   $tweet_args = array(
        'public' => true,
        'rewrite' => array(
            'slug' => 'tweets',
            'with_front' => false,
            'pages' => false
        ),
        'supports' => array(
            'title'
        ),
        'labels' => array(
            'name' => 'Tweety',
            'singular_name' => 'Tweet',
            'add_new' => 'Dodaj nowy Tweet',
            'add_new_item' => 'Dodaj nowy Tweet',
            'edit_item' => 'Edytuj Tweet',
            'new_item' => 'Nowy Tweet',
            'view_item' => 'Wyswietl Tweet',
            'search_items' => 'Wyszukaj Tweety',
            'not_found' => 'Tweetów nie znaleziono',
            'not_found_in_trash' => 'Brak usuniętych Tweetów'
        ),
        'has_archive' => true,
        'menu_position' => 4
    );
   register_post_type( 'tweets', $tweet_args );
}


some info about using shortcodes:
Code: Select all
add_action( 'init', 'cs_register_form_shortcode' );
function cs_register_form_shortcode() {
    add_shortcode( 'dodajpoleinput', 'cs_form_input_shortcode' );
    add_shortcode( 'dodajpoletextarea', 'cs_form_textarea_shortcode' );
    add_shortcode( 'grupujpola', 'cs_form_group_elements' );
}

function cs_form_input_shortcode($atts){
//parametry
//nazwa skrocona (przekazywana z formularzem, unikalna)
//nazwa pelna (Imie i Nazwisko, e-mail )
//rodzaj validacji (brak, email, telefon, nip, niepuste, imienazwisko)
   $defaults = array(
      'tytul' => "Puste pole",
      'skrocona' => "emptyfield",
      'validuj' => "" //nie, email, telefon, nip, niepuste
   );
   extract( shortcode_atts( $defaults, $atts ) );
   if ($validuj == 'nie' || $validuj == '') {
      $star = '';
      $type = '';
   } elseif ($validuj == 'email') {
      $star = '*';
      $type = ' validateme email';
   } elseif ($validuj == 'telefon') {
      $star = '*';
      $type = ' validateme telefon';   
   } elseif ($validuj == 'nip') {
      $star = '*';
      $type = ' validateme nip';
   } elseif ($validuj == 'niepuste') {
      $star = '*';
      $type = ' validateme niepuste';
   } else {
      $star = '*';
      $type = ' validateme niepuste';
   }
   
   //$output = '<tr><td class="label">'.$tytul.$star.'</td><td id="_'.$skrocona.'"><input type="text" name="'.$skrocona.'" class="input_field clear" style="color:#4c4e51;" /></td></tr>';
   $output = '<div class="rowholder"><div class="elementsholder"><label for="id_'.$skrocona.'">'.$tytul.' '.$star.'</label><input type="text" id="id_'.$skrocona.'" name="'.$skrocona.'" class="input_field clear'.$type.'" /></div></div>';
   return $output;
}

function cs_form_textarea_shortcode($atts) {
   $defaults = array(
      'tytul' => "Puste pole",
      'skrocona' => "emptyfield",
      'validuj' => "" //nie, email, telefon, nip, niepuste
   );
   extract( shortcode_atts( $defaults, $atts ) );
   if ($validuj == 'nie' || $validuj == '') {
      $star = '';
      $type = '';
   } elseif ($validuj == 'email') {
      $star = '*';
      $type = ' validateme email';
   } elseif ($validuj == 'telefon') {
      $star = '*';
      $type = ' validateme telefon';   
   } elseif ($validuj == 'nip') {
      $star = '*';
      $type = ' validateme nip';
   } elseif ($validuj == 'niepuste') {
      $star = '*';
      $type = ' validateme niepuste';
   } else {
      $star = '*';
      $type = ' validateme niepuste';
   }
   $output = '<div class="rowholder"><div class="elementsholder"><label for="id_'.$skrocona.'">'.$tytul.' '.$star.'</label><textarea id="id_'.$skrocona.'" name="'.$skrocona.'" class="input_field clear'.$type.'"></textarea></div></div>';
   return $output;
}

function cs_form_group_elements($atts, $content = null){
   return '<div class="grouped">'.do_shortcode($content).'</div>';
}


Those are saples from one of my projects, and show logic and functions that can be used to create both CPT and shortcode.
User avatar
Moderator

GK User
Wed Aug 21, 2013 4:04 pm
Thanks so much!! here is the url to my site:

http://integralmedicine.ca/

I downloaded CPT UI and I'm trying to work with that.
User avatar
Gold Boarder

GK User
Fri Aug 23, 2013 7:30 pm
Keeing fingers crossed.
User avatar
Moderator

GK User
Fri Aug 23, 2013 7:36 pm
CPT UI plugin works great. Thanks
User avatar
Gold Boarder


cron