Support » Plugins » One post per category

  • I have tried the other posts but they do nothing. I am a complete noob so I need step by step guide on how to make it so I only have one post show up for only one specific category.

Viewing 15 replies - 1 through 15 (of 23 total)
  • Where do you want this limit to take place?

    Which category?

    What theme are you using?

    URL to see the site in question…please.

    Umm first of its a NSFW site, I want it to take place on the front page, I want the category to be the second categor which is called Picture of the Day and the theme is Mystique.
    http://wordpress.org/extend/themes/mystique

    Sorry not clear enough…so will give you some general ideas:

    http://www.google.com/search?q=wordpress+display+featured+category

    Well the site is http://www.mysterious-girl.net

    NSFW
    NSFW

    Yep got that…

    Cant find anything in regards to only showing one post for one specific category. I tried using the code you posted for a issue of the same nature, before the loop but to no avail.

    <?php
      $args=array(
        'cat' => 3,
        'post_type' => post,
        'post_status' => 'publish',
        'showposts' => 1,
        'caller_get_posts'=> 1
        );
      $my_query = null;
      $my_query = new WP_Query($args);
      if( $my_query->have_posts() ) {
        while ($my_query->have_posts()) : $my_query->the_post(); ?>
          <p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
         <?php
        the_content();
        endwhile;
      } //if ($my_query)
    } // foreach
    wp_reset_query();  // Restore global post data stomped by the_post().
    ?>
    <?php
     /* Mystique/digitalnature */
     get_header();
    ?>
    
      <!-- main content: primary + sidebar(s) -->
      <div id="main">
       <div id="main-inside">
        <!-- primary content -->
        <div id="primary-content">
    
    <strong><?php
      $args=array(
        'cat' => 2,
        'post_type' => post,
        'post_status' => 'publish',
        'showposts' => 1,
        'caller_get_posts'=> 1
        );
      $my_query = null;
      $my_query = new WP_Query($args);
      if( $my_query->have_posts() ) {
        while ($my_query->have_posts()) : $my_query->the_post(); ?>
          <p><a>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
         <?php
        the_content();
        endwhile;
      } //if ($my_query)
    } // foreach
    wp_reset_query();  // Restore global post data stomped by the_post().
    ?></strong>
          <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
            <div class="page-navigation">

    The bold code is the code you gave me, this code goes before the loop in Single.php correct?

    It comes up with an error on line 29 error } expected. Which is: } //if ($my_query)

    Oops, delete this

    } // foreach

    Btw thank you so so so much for your help so far. It is really really appreciated.

    There is no line 118 there.

    Also you need to delete one of these sets — you have two in a row:

    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
            <div class="page-navigation">

    Yeah I was a bit hastey on the ctrl + P there; it seems to have been implemented well, however all the posts of that category are still showing on the page.

    <?php
     /* Mystique/digitalnature */
     get_header();
    ?>
    
      <!-- main content: primary + sidebar(s) -->
      <div id="main">
       <div id="main-inside">
        <!-- primary content -->
        <div id="primary-content">
    
    <strong><?php
      $args=array(
        'cat' => 4,
        'post_type' => post,
        'post_status' => 'publish',
        'showposts' => 1,
        'caller_get_posts'=> 1
        );
      $my_query = null;
      $my_query = new WP_Query($args);
      if( $my_query->have_posts() ) {
        while ($my_query->have_posts()) : $my_query->the_post(); ?>
          <p><a>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
         <?php
        the_content();
        endwhile;
      } //if ($my_query)
    
    wp_reset_query();  // Restore global post data stomped by the_post().
    ?></strong>
          <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
            <div class="page-navigation">
              <div class="alignleft"><?php previous_post_link('&laquo; %link') ?></div>
              <div class="alignright"><?php next_post_link('%link &raquo;') ?></div>
              <div class="clear"></div>
            </div>
    
            <!-- post -->
            <div id="post-<?php the_ID(); ?>" <?php if (function_exists("post_class")) post_class(); else print 'class="post"'; ?>>
               <?php if (!get_post_meta($post->ID, 'hide_title', true)): ?><h1 class="title"><?php the_title(); ?></h1><?php endif; ?>
    
                  <div class="post-content clearfix">
        	       <?php the_content(__('Read the rest of this entry &raquo;', 'mystique')); ?>
                  </div>
                  <?php wp_link_pages(array('before' => '<div class="page-navigation"><p><strong>Pages: </strong> ', 'after' => '</p></div>', 'next_or_number' => 'number')); ?>
                  <?php
                  $posttags = get_the_tags();
                  if ($posttags): ?>
                  <div class="post-tags"> <?php the_tags(__('Tags:','mystique').' ', ', ', ''); ?></div>
                  <?php endif; ?>
                  <div class="post-meta">
                        <?php
                         if(get_mystique_option('sharethis') && get_mystique_option('jquery')) $share = true;
                         if ($share) shareThis();
                        ?>
                        <div class="details<?php if($share):?> share<?php endif; ?>">
                        <?php
                        printf(__('This entry was posted on %s at %s, and is filed under %s. Follow any responses to this post through %s.', 'mystique'), get_the_time(get_option('date_format')),get_the_time(get_option('time_format')), get_the_category_list(', '), '<a href="'.get_post_comments_feed_link($post->ID).'" title="RSS 2.0">RSS 2.0</a>');echo ' ';
    
                        if (('open' == $post-> comment_status) && ('open' == $post->ping_status)):
                          // Both Comments and Pings are open
                          printf(__('You can <a%s>leave a response</a> or <a%s>trackback</a> from your own site.', 'mystique'), ' href="#respond"',' href="'.trackback_url('',false).'" rel="trackback"');
    
                          elseif (!('open' == $post-> comment_status) && ('open' == $post->ping_status)):
                          // Only Pings are Open
                          printf(__('Responses are currently closed, but you can <a%s>trackback</a> from your own site.', 'mystique'), ' href="'.trackback_url('',false).'" rel="trackback"');
    
                          elseif (('open' == $post-> comment_status) && !('open' == $post->ping_status)):
                          // Comments are open, Pings are not
                          _e('You can skip to the end and leave a response. Pinging is currently not allowed.','mystique');
    
                          elseif (!('open' == $post-> comment_status) && !('open' == $post->ping_status)):
                          // Neither Comments, nor Pings are open
                          _e('Both comments and pings are currently closed.','mystique');
                        endif; ?>
                        <?php edit_post_link(__('Edit this entry', 'mystique')); ?>
                        </div>
                        <div class="clear"></div>
    
        		  </div>
    
            </div>
            <!-- /post -->
    
           <?php endwhile; endif; ?>
    
           <?php include(TEMPLATEPATH . '/lib/post-meta.php'); ?>
    
           <?php comments_template(); ?>
    
        </div>
        <!-- /primary content -->
    
        <?php get_sidebar(); ?>
    
        <div class="clear"></div>
    
       </div>
      </div>
      <!-- /main content -->
    
    <?php get_footer(); ?>

    This is my current code.

Viewing 15 replies - 1 through 15 (of 23 total)
  • The topic ‘One post per category’ is closed to new replies.