Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

i've got several posts which are tagged with "design", but also a page called "design".

my question: i put some text into the design-page and would then display all posts which are tagged by "design". how is that possible? can i put a placeholder directly into the text or do i have to code it by myself in php?

thx

share|improve this question
add comment

3 Answers

up vote 2 down vote accepted

You could easily modify the page template of your theme to include a section that reads "Related Posts" at the bottom and then execute a simple PHP query to get posts as follows:

<?php query_posts('category_name=wordpress&showposts=5'); ?>
<?php while (have_posts()) : the_post(); ?>
   <li>
      <a href="<?php the_permalink(); ?>">
      <?php the_title(); ?>
      </a>
   </li>
<?php endwhile; ?>

You'd need to tweak the category accordingly, and you could always format the post listing the way you want.

share|improve this answer
add comment

Easiest way would be to turn your 'Design' tag into a 'Design' Category and then use the Category archive page as the page by putting your page content into the Category description (although that lacks the rich text editor by default) and adjusting your theme to format it nicely.

share|improve this answer
add comment

Use a page template to do a regular loop, then create a new WP_Query object and fetch posts with a tag that matches the page name(ie. the slug).

Here's one i prepared earlier..

<?php
/**
  * Template Name: Page with tagged Posts
  */
get_header();
?>

<div id="container">
    <div id="content">
        <?php the_post(); ?>
        <div <?php post_class(); ?>>
            <h2 class="entry-title">
                <?php the_title();?>
            </h2>
            <div class="entry-content">
                <?php the_content(); ?>
            </div>
        </div>

        <?php 
        $tagged_posts = new WP_Query; 
        $tagged_posts->query( array( 'tag__slug_in' => array( $post->post_name ) ) ); 

        if( $tagged_posts->have_posts() ) :
            while( $tagged_posts->have_posts() ) : $tagged_posts->the_post();
            ?>

                <div <?php post_class(); ?>>
                    <h2 class="entry-title">
                        <?php the_title();?>
                    </h2>
                    <div class="entry-content">
                        <?php the_content(); ?>
                    </div>
                </div>

            <?php
            endwhile;
        endif;

        wp_reset_query();
        ?>

    </div>
</div>
<?php //get_sidebar(); ?>
<?php get_footer(); ?>

Hope that helps..

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.