The Support Forums will be in read-only mode for a scheduled maintenance window on 01 September 2016 14:00 UTC - 20:00 UTC. More information.

WP Parallax Content Slider
[resolved] Use with custom post types (5 posts)

  1. OakesDesign
    Posted 3 years ago #

    Is there any way to use the slide show with custom post type posts?

    I have made a custom post type and category and set the slide show to grab from the CPT but it does not grab any of the posts. If I use normal posts it works fine...

    Any help would be great, thanks!


  2. wp-maverick
    Plugin Author

    Posted 3 years ago #

    Hey OakesDesign,
    Choosing to add automatically custom post types and pages will be a feature in next version.
    In the meanwhile, you can add your custom type name, as the type 'page' if you want, in the plugin PHP code. On line 105 you’ll have to adapt the following line :

    $args = array( 'post_type' => array('post'),

    with this

    $args = array( 'post_type' => array('post','page', 'XXXX'),

    Where XXXXX will be the name of yout custom type.

    This custom type must have a title, a content and a featured image of course ;)

    Let me know if this code works for you!

  3. wp-maverick
    Plugin Author

    Posted 3 years ago #

    OK, works fine for me with this code.
    To display you own custom types, you'll have to change the code manually.
    I've added a new parameter in v0.9.2 to choose between posts, pages or both (regular post types)

  4. Joan Junyent Tarrida
    Posted 3 years ago #

    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')

    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;
  5. wp-maverick
    Plugin Author

    Posted 3 years ago #

    Hello jjunyent,
    great work.
    Actually, I wanted to do something new in v1.0 to simplify things about "static slides". I've decided to replace this fonctionnality by adding a new custom post type. User will have the choice to display:

    • posts
    • pages
    • this new custom-post-type : parallax-slides

    I'll certainly reuse some of you're code ;)

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • WP Parallax Content Slider
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic