Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)
  • I needed to create a custom version that showed the contents of a custom post type.

    I set up a new custom post type called slides

    $labels = array(
      	'name' => _x('Slides', 'slide'),
      	'singular_name' => _x('Slide', 'slide'),
      	'add_new' => _x('Add New Slide', 'slide'),
      	'add_new_item' => __('Add New publication'),
      	'edit_item' => __('Edit slide'),
      	'new_item' => __('New slide'),
      	'view_item' => __('View slide'),
      	'search_items' => __('Search slide'),
      	'not_found' =>  __('No slides found'),
      	'not_found_in_trash' => __('No slide found in Trash'),
      	'parent_item_colon' => ''
        );
        $args = array(
      	'labels' => $labels,
      	'public' => true,
      	'publicly_queryable' => true,
      	'show_ui' => true,
      	'query_var' => true,
      	'rewrite' => true,
      	'capability_type' => 'post',
      	'hierarchical' => false,
      	'menu_position' => null,
      	'supports' => array('title','editor','author','thumbnail','excerpt','comments')
    );
        register_post_type('slide',$args);

    then modified you plugin in order to select only the slide post type

    $args = array( 'post_type' => array('slide'), // not 'page'
    					   'orderby' => $prlx_sort,
    					   'order' => $prlx_order,
    					   'numberposts' =>  $prlx_slider_nb_articles,
    					   'cat' => $cat );
    
    		$myposts = get_posts( $args );
    
    		// --------------------------------------------------------
    		// HTML Output beginning

    and finally tweaked the output display in order to show the contents and thumbnail:

    /*
    	 * Generate HTML output for an article slide
    	 */
    	function get_article_slide($title, $content, $link_article, $url_image, $title_length, $alt_image = 'Alternative text')
    	{
    		// Parameters
    		if (strlen($title) > $title_length) $title = substr($title, 0, $title_length)."...";
    
    		// Slide output
    		$outputSlide  = "<div class='da-slide'>"."\n";
    		$outputSlide .= "<h2>".$title."</h2>"."\n";
    		$outputSlide .= $content."\n";
    		// $outputSlide .= "<a href='".$link_article."' class='da-link'>Read more</a>"."\n";
    		$outputSlide .= "<div class='da-img'><img src='".$url_image."' alt='".$alt_image."' /></div>"."\n";
    		$outputSlide .= "</div>"."\n";
    		return $outputSlide;
    	}
    Plugin Author Joan Junyent Tarrida

    (@jjunyent)

    The easiest way o display a publications page would be to create a new page template (e.g. cloning the archive or the index template) and add the following code before the loop.

    query_posts( 'post_type=publications');

    You can also create a custom template for the single publications view by naming it single-publication.php

Viewing 2 replies - 1 through 2 (of 2 total)