Forum Replies Created

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter p2or

    (@p2or)

    awesome!

    Thread Starter p2or

    (@p2or)

    Solved. To get the categories of a custom post type you have call get_the_terms() and setup the registered category name like this:

    <?php
    $terms = get_the_terms( $post->ID , 'myposttype_category' );
    foreach ( $terms as $term ) {
      echo $term->name;
    }
    ?>

    Best,
    Christian

    Thread Starter p2or

    (@p2or)

    Hey keesiemeijer,

    thanks for your reply. Thats much better than my first try. Here is my current code:

    <?php
    function shortcode( $atts, $content = null ) {
    
    	extract( shortcode_atts( array(
    				'customClass' => '',
    				'customColor' => '',
    			), $atts ) );
    
    	if ( $customClass || $customColor ) {
    
    		// rewrite class
    		$class = 'myClass';
    		$class .= ( $customClass ) ? ' customClass_' . $customClass : '';
    
    		// add styling
    		$style  = ( $customColor ) ? ' style="color:' . $customColor . '"' : '';
    
    		// join strings
    		$output = '<div class="' . $class . '"'. $style .'>' . do_shortcode($content) . '</div>';
    
    	} else {
    		$output = '<div class="myClass">' . do_shortcode($content) . '</div>';
    	}
    
    	return $output;
    }
    ?>

    Thank you very much,
    Christian

    Thread Starter p2or

    (@p2or)

    <!-- get pagetitle -->
    	<?php $page_title = $wp_query->post->post_title; ?>
    	<?php echo ($page_title) ?>
    
    	<!-- if pagename is X - blog loop -->
    	<?php if ($page_title == 'sasadda'){
    
    		$temp = $wp_query;
    		$wp_query= null;
    		$wp_query = new WP_Query();
    		$wp_query->query('posts_per_page=7'.'&paged='.$paged);
    		while ($wp_query->have_posts()) : $wp_query->the_post();?>
    
    		<h1><?php the_title(); ?></h1>
    		<?php the_content(); ?>
    		<?php wp_link_pages( array( 'before' => '' . __( 'Pages:', 'boilerplate' ), 'after' => '' ) ); ?>
    		<?php edit_post_link( __( 'Edit', 'boilerplate' ), '', '' ); ?>
    
    		<?php comments_template( '', true ); ?>
    
    		<?php endwhile;
    
    		$wp_query = null; $wp_query = $temp;
    
    	}
    	?>

    I fixed it with a simple statement in the main loop, but is there a more elegant/dynamic way to use this in a page template?

    thanks

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