• Resolved CaiusMartius

    (@caiusmartius)


    I have a website specifically with this page.

    It is category page that simply lists ‘characters’. What I would like to do is at the end of EACH character have it “Name” the actor who is playing the role.

    For example
    ******
    Buttercup
    The perfect soldier. […] out.

    Butttercup is played by ‘Actor’s Name Here.”
    ******

    Characters are setup as:
    – Category: Rogue’s Gallery
    – Tags: “Character Name” (specific to the character, i.e. Buttercup, DJ, etc.)

    Actors are setup as:
    – Category: Cast
    – Tags: “Character Name” (specific to the character, i.e. Buttercup, DJ, etc.)

    What I have not been able to figure out how to do is loop it so the incoming ‘post’ notes everything related and displays it.

    Any help would be appreciated it.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter CaiusMartius

    (@caiusmartius)

    Ok.

    I’ve actually got this mostly figured out. HOWEVER, for seem reason it’s repeating the very first post (see the linked page above).

    Here is my current code setup.

    <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    			<div class="entry-wrapper">
    				<div class="header-wrapper">
    					<?php the_title( '<h1 class="entry-title">', '</h1>' ); ?>
    				</div><!-- .site-branding -->
    				<?php
    				 if ( has_post_thumbnail()) {
    				   $large_image_url = wp_get_attachment_image_src( get_post_thumbnail_id(), 'large');
    				   echo '<div class="tag-img">';
    				   the_post_thumbnail('large');
    				   echo '</div>';
    				 }
    				 ?>
    				<div class="entry-content">
    					<?php the_content(); ?>
    					<?php
    						$orig_post = $post;
    						global $post;
    						$tags = wp_get_post_tags($post->ID);
    
    						if ($tags) {
    							$tag_ids = array();
    						foreach($tags as $individual_tag) $tag_ids[] = $individual_tag->term_id;
    							$args=array(
    								'tag__in' => $tag_ids,
    								'post__not_in' => array($post->ID),
    								'caller_get_posts'=>1
    							);
    
    						$my_query = new wp_query( $args );
    
    						while( $my_query->have_posts() ) {
    							$my_query->the_post();
    
     						if ( has_post_thumbnail()) {
     						?>
     							<div class="relatedthumb">
     								<a href="<? the_permalink()?>">
    								<?php
    								the_post_thumbnail();
    								?>
    								<br />Played by
    								<?php
    								the_title();
    								?>
     								</a>
     							</div>
     						<?php
      								}
    							}
    						}
    						$post = $orig_post;
    						wp_reset_query();
    					?>
    				</div><!-- .entry-content -->
    			</div>
    		<!-- .entry-footer -->
    </article><!-- #post-## -->
    Thread Starter CaiusMartius

    (@caiusmartius)

    Solved. Removed wp_reset(query); at the very end and it worked like a charm.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Display Title of Another post based on Tags’ is closed to new replies.