Skip to main content
added 1415 characters in body
Source Link
Johan Dahl
  • 1.3k
  • 3
  • 19
  • 32

Edit. Ok I got this working.

Code:

                <?php
            $taxonomy = 'fastighetslista';//  e.g. post_tag, category, custom taxonomy
            $param_type = 'fastighetslista'; //  e.g. tag__in, category__in, but genre__in will NOT work
            $post_types = get_post_types( array('public' => true), 'names' );
            $tax_args=array('orderby' => 'none');
            $tags = wp_get_post_terms( $post->ID , $taxonomy, $tax_args); ?>
            <?php
            if ($tags) ?>
              <?php foreach ($tags as $tag) ?>
              <?php
                $args=array(
                "$param_type" => $tag->slug,
                'post__not_in' => array($post->ID),
                'post_type' => $post_types,
                'showposts'=> 10,
                'caller_get_posts'=>1
            );
            $my_query = null;
            $my_query = new WP_Query($args); ?>
            
            <?php if( $my_query->have_posts() ) : ?>
            <?php while( $my_query->have_posts() ) : $my_query->the_post(); ?>
            
            <div class="press-entry-small">
            <div class="press-entry-date-small">
            <p class="press-day-small"><?php the_time('d'); ?></p>
            <p class="press-month-small"><?php the_time('M'); ?></p>
            </div>
            
            <li class="news-link"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
            </div>
            
            <div class="clear"></div>
            <!-- your output here -->
            <?php endwhile; else : ?>
            Blablabla               
            <?php endif; ?>

Edit. Ok I got this working.

Code:

                <?php
            $taxonomy = 'fastighetslista';//  e.g. post_tag, category, custom taxonomy
            $param_type = 'fastighetslista'; //  e.g. tag__in, category__in, but genre__in will NOT work
            $post_types = get_post_types( array('public' => true), 'names' );
            $tax_args=array('orderby' => 'none');
            $tags = wp_get_post_terms( $post->ID , $taxonomy, $tax_args); ?>
            <?php
            if ($tags) ?>
              <?php foreach ($tags as $tag) ?>
              <?php
                $args=array(
                "$param_type" => $tag->slug,
                'post__not_in' => array($post->ID),
                'post_type' => $post_types,
                'showposts'=> 10,
                'caller_get_posts'=>1
            );
            $my_query = null;
            $my_query = new WP_Query($args); ?>
            
            <?php if( $my_query->have_posts() ) : ?>
            <?php while( $my_query->have_posts() ) : $my_query->the_post(); ?>
            
            <div class="press-entry-small">
            <div class="press-entry-date-small">
            <p class="press-day-small"><?php the_time('d'); ?></p>
            <p class="press-month-small"><?php the_time('M'); ?></p>
            </div>
            
            <li class="news-link"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
            </div>
            
            <div class="clear"></div>
            <!-- your output here -->
            <?php endwhile; else : ?>
            Blablabla               
            <?php endif; ?>
deleted 67 characters in body
Source Link
Johan Dahl
  • 1.3k
  • 3
  • 19
  • 32

Edit (again).

        <?php
            // Loop in the ten latest news with the same taxonomy term as the current post<?php
            $taxonomy = 'fastighetslista';//  e.g. post_tag, category, custom taxonomy
            $param_type = 'fastighetslista'; //  e.g. tag__in, category__in, but genre__in will NOT work
            $post_types = get_post_types( array('public' => true), 'names' );
            $tax_args=array('orderby' => 'none');
            $tags = wp_get_post_terms( $post->ID , $taxonomy, $tax_args);
            if ($tags) {
              foreach ($tags as $tag) {
                $args=array(
                "$param_type" => $tag->slug,
                'post__not_in' => array($post->ID),
                'post_type' => $post_types,
                'showposts'=> 10,
                'caller_get_posts'=>1
            );
            $my_query = null;
            $my_query = new WP_Query($args); ?>
            
            <?php if( $my_query->have_posts() ) : ?>
            <?php while( $my_query->have_posts() ) : $my_query_the_post$my_query->the_post(); ?>
            
            <div class="press-entry-small">
            <div class="press-entry-date-small">
            <p class="press-day-small"><?php the_time('d'); ?></p>
            <p class="press-month-small"><?php the_time('M'); ?></p>
            </div>
            
            <li class="news-link"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
            </div>
            
            <div class="clear"></div>
            <!-- your output here -->
            <?php endwhile; else : ?>
             <!-- your failure output here -->
            <?php endif; ?>
            <?php wp_reset_query(); ?>

Edit.

        <?php
            // Loop in the ten latest news with the same taxonomy term as the current post
            $taxonomy = 'fastighetslista';//  e.g. post_tag, category, custom taxonomy
            $param_type = 'fastighetslista'; //  e.g. tag__in, category__in, but genre__in will NOT work
            $post_types = get_post_types( array('public' => true), 'names' );
            $tax_args=array('orderby' => 'none');
            $tags = wp_get_post_terms( $post->ID , $taxonomy, $tax_args);
            if ($tags) {
              foreach ($tags as $tag) {
                $args=array(
                "$param_type" => $tag->slug,
                'post__not_in' => array($post->ID),
                'post_type' => $post_types,
                'showposts'=> 10,
                'caller_get_posts'=>1
            );
            $my_query = null;
            $my_query = new WP_Query($args); ?>
            
            <?php if( $my_query->have_posts() ) : ?>
            <?php while( $my_query->have_posts() ) : $my_query_the_post(); ?>
            
            <div class="press-entry-small">
            <div class="press-entry-date-small">
            <p class="press-day-small"><?php the_time('d'); ?></p>
            <p class="press-month-small"><?php the_time('M'); ?></p>
            </div>
            
            <li class="news-link"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
            </div>
            
            <div class="clear"></div>   
            <?php endwhile; else : ?>
             <!-- your failure output here -->
            <?php endif; ?>
            <?php wp_reset_query(); ?>

Edit (again).

                        <?php
            $taxonomy = 'fastighetslista';//  e.g. post_tag, category, custom taxonomy
            $param_type = 'fastighetslista'; //  e.g. tag__in, category__in, but genre__in will NOT work
            $post_types = get_post_types( array('public' => true), 'names' );
            $tax_args=array('orderby' => 'none');
            $tags = wp_get_post_terms( $post->ID , $taxonomy, $tax_args);
            if ($tags) {
              foreach ($tags as $tag) {
                $args=array(
                "$param_type" => $tag->slug,
                'post__not_in' => array($post->ID),
                'post_type' => $post_types,
                'showposts'=> 10,
                'caller_get_posts'=>1
            );
            $my_query = null;
            $my_query = new WP_Query($args); ?>
            
            <?php if( $my_query->have_posts() ) : ?>
            <?php while( $my_query->have_posts() ) : $my_query->the_post(); ?>
            
            <div class="press-entry-small">
            <div class="press-entry-date-small">
            <p class="press-day-small"><?php the_time('d'); ?></p>
            <p class="press-month-small"><?php the_time('M'); ?></p>
            </div>
            
            <li class="news-link"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
            </div>
            
            <div class="clear"></div>
            <!-- your output here -->
            <?php endwhile; else : ?>
            <!-- your failure output here -->
            <?php endif; ?>
added 1530 characters in body
Source Link
Johan Dahl
  • 1.3k
  • 3
  • 19
  • 32

Edit.

Ok I modified the code, It looks like this now, but it´s not working at all.

        <?php
            // Loop in the ten latest news with the same taxonomy term as the current post
            $taxonomy = 'fastighetslista';//  e.g. post_tag, category, custom taxonomy
            $param_type = 'fastighetslista'; //  e.g. tag__in, category__in, but genre__in will NOT work
            $post_types = get_post_types( array('public' => true), 'names' );
            $tax_args=array('orderby' => 'none');
            $tags = wp_get_post_terms( $post->ID , $taxonomy, $tax_args);
            if ($tags) {
              foreach ($tags as $tag) {
                $args=array(
                "$param_type" => $tag->slug,
                'post__not_in' => array($post->ID),
                'post_type' => $post_types,
                'showposts'=> 10,
                'caller_get_posts'=>1
            );
            $my_query = null;
            $my_query = new WP_Query($args); ?>
            
            <?php if( $my_query->have_posts() ) : ?>
            <?php while( $my_query->have_posts() ) : $my_query_the_post(); ?>
            
            <div class="press-entry-small">
            <div class="press-entry-date-small">
            <p class="press-day-small"><?php the_time('d'); ?></p>
            <p class="press-month-small"><?php the_time('M'); ?></p>
            </div>
            
            <li class="news-link"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
            </div>
            
            <div class="clear"></div>   
            <?php endwhile; else : ?>
             <!-- your failure output here -->
            <?php endif; ?>
            <?php wp_reset_query(); ?>

Edit.

Ok I modified the code, It looks like this now, but it´s not working at all.

        <?php
            // Loop in the ten latest news with the same taxonomy term as the current post
            $taxonomy = 'fastighetslista';//  e.g. post_tag, category, custom taxonomy
            $param_type = 'fastighetslista'; //  e.g. tag__in, category__in, but genre__in will NOT work
            $post_types = get_post_types( array('public' => true), 'names' );
            $tax_args=array('orderby' => 'none');
            $tags = wp_get_post_terms( $post->ID , $taxonomy, $tax_args);
            if ($tags) {
              foreach ($tags as $tag) {
                $args=array(
                "$param_type" => $tag->slug,
                'post__not_in' => array($post->ID),
                'post_type' => $post_types,
                'showposts'=> 10,
                'caller_get_posts'=>1
            );
            $my_query = null;
            $my_query = new WP_Query($args); ?>
            
            <?php if( $my_query->have_posts() ) : ?>
            <?php while( $my_query->have_posts() ) : $my_query_the_post(); ?>
            
            <div class="press-entry-small">
            <div class="press-entry-date-small">
            <p class="press-day-small"><?php the_time('d'); ?></p>
            <p class="press-month-small"><?php the_time('M'); ?></p>
            </div>
            
            <li class="news-link"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
            </div>
            
            <div class="clear"></div>   
            <?php endwhile; else : ?>
             <!-- your failure output here -->
            <?php endif; ?>
            <?php wp_reset_query(); ?>
Fixed code formatting issues
Source Link
mor7ifer
  • 8.6k
  • 2
  • 19
  • 32
Loading
Source Link
Johan Dahl
  • 1.3k
  • 3
  • 19
  • 32
Loading