Forum Replies Created

Viewing 15 replies - 466 through 480 (of 482 total)
  • Hey Jenny, if you wanted to use an include file, you would need to create a file. Let’s call if fiveposts.php. You would paste the following code in and save it in your directory:

    <div class="recent-five-posts">
    <?php query_posts("orderby=desc&showposts=5"); ?>
    
    <?php while (have_posts()) : the_post(); ?>
    
    <div class="individual-posts">
    <h3><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h3>
    <?php the_excerpt(); ?>
    </div>
    
    <?php endwhile; ?>
    </div>

    Then, wherever you wanted this code to appear in your template, you would use this line of code:

    <?php include( TEMPLATEPATH . '/fiveposts.php' ); ?>

    If you wanted the five posts to appear on your home page, you would need to put this code in your home.php or index.php file.

    Hey Jenny. Sorry ’bout the errors. Go ahead and replace the text “Read More” with this little bit of php:

    <?php the_title(); ?>

    I think there are plug-ins that allow you to limit the excerpt length to less than 100 characters- but probably the easiest way for you to get the text you want there is to write one manually.

    To do this, edit your most recent post, then scroll down below the content area. There should be a field marked “Excerpt” where you can put in content. If you want something less than 100 characters, that’s what you should type here.

    Not sure where your include file didn’t work. I’ll take a look when I can to make sure there isn’t a typo.

    If you really want this in a separate file, you can save this snippet of code and then call it with:

    <?php include(TEMPLATEPATH . 'file-name.php'); ?>

    Or you could just paste this into your template:

    <div class="recent-five-posts">
    <?php query_posts("orderby=desc&showposts=5"); ?>
    
    <?php while (have_posts()) : the_post(); ?>
    
    <div class="individual-posts">
    <h3><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>">Read More</a></h3>
    <?php the_excerpt(); ?>
    </div>
    
    <?php endwhile; ?>
    </div>
    Forum: Your WordPress
    In reply to: Feedback please!

    Looks nice. Maybe a little more padding in your sidebar.

    If you don’t have a single.php file, it means your theme is defaulting to index.php. You can follow adamcorley’s advice above, but use index.php instead of single.php.

    You could also set up conditional statements, which is more difficult, but would be useful if you want to exclude multiple pages/posts through the code. You would replace <?php get_sidebar();> in the index.php with the following code. Instead of page-slug, your would put the actual page slug for the page you didn’t want to have the sidebar.

    <?php
    
    global $post;     // if outside the loop
    
    if (is_page('page-slug') {
        // Do nothing 
    
    } else {
        get_sidebar();
    }
    ?>

    I would suggest taking a look at the code for other themes that do this type of thing. Try looking at the Magazeen Theme from We Function.

    The Query Posts function will be your friend on this one.

    For instance, if you have a category called “Featured Posts”, and you want your first five posts from this category to show up somewhere on the home page, you could put this code somewhere in your index.php file:

    <div class="featured-articles">
                <h3>Featured Articles</h3>
                <?php query_posts("category_name=Featured Articles&orderby=desc&showposts=5"); ?>
                <?php while (have_posts()) : the_post(); ?>
                <div>
    
                    <h3><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"></a></h3>
           <?php the_excerpt(); ?>
                    </div>
                <?php endwhile; ?>
            </div>

    Hi Billkoe. You simply need to add another item to the menu. Open your nav.php and put the following before the close ul tag:

    <li><a href="<?php bloginfo('rss2_url'); ?>">Subscribe</a></li>

    Here’s what the whole thing should look like when you are finished:

    <!-- Navigation -->
      <div id="nav">
        <ul class="sf-menu">
          <li><a href="#">Categories</a>
            <ul>
    			<?php wp_list_categories('orderby=name&title_li='); ?>
            </ul>
          </li>
          <li><a href="#">Pages</a>
            <ul>
            	<?php wp_list_pages('orderby=name&title_li='); ?>
            </ul>
          </li>
          <li><a href="#">Contact</a>
            <ul>
              <li><a href="#">1-800-867-5309</a></li>
              <li><a href="mailto:[email protected]">[email protected]</a></li>
            </ul>
          </li>
          <li><a href="#">Search</a>
            <ul>
              <li><?php if(function_exists('get_search_form')) : ?>
    				<?php get_search_form(); ?>
    				<?php else : ?>
    				<?php include (TEMPLATEPATH . '/searchform.php'); ?>
    				<?php endif; ?></li>
            </ul>
          </li>
          <li><a href="<?php bloginfo('rss2_url'); ?>">Subscribe</a></li>
        </ul>
      </div>

    Hi Billkoe. You simply need to add another item to the menu. Open your nav.php and put the following at before the close ul tag:

    <li><a href="<?php bloginfo('rss2_url'); ?>">Subscribe</a></li>

    Here’s what the whole thing should look like when you are finished:

    <!-- Navigation -->
      <div id="nav">
        <ul class="sf-menu">
          <li><a href="#">Categories</a>
            <ul>
    			<?php wp_list_categories('orderby=name&title_li='); ?>
            </ul>
          </li>
          <li><a href="#">Pages</a>
            <ul>
            	<?php wp_list_pages('orderby=name&title_li='); ?>
            </ul>
          </li>
          <li><a href="#">Contact</a>
            <ul>
              <li><a href="#">1-800-867-5309</a></li>
              <li><a href="mailto:[email protected]">[email protected]</a></li>
            </ul>
          </li>
          <li><a href="#">Search</a>
            <ul>
              <li><?php if(function_exists('get_search_form')) : ?>
    				<?php get_search_form(); ?>
    				<?php else : ?>
    				<?php include (TEMPLATEPATH . '/searchform.php'); ?>
    				<?php endif; ?></li>
            </ul>
          </li>
          <li><a href="<?php bloginfo('rss2_url'); ?>">Subscribe</a></li>
        </ul>
      </div>

    Where did you download the template? I’ll take a look through the files.

    Can you paste the header/navigation source in so we can take a look?

    My page attributes are also missing. I am attributing this to the Flutter plug-in (though I am not entirely sure).

    Same problem as others:

    <div id=”pageparentdiv” class=”postbox ” style=”display:none;”>

    I found this resource and tried to run the SQL query, but no dice. Perhaps I just did it wrong. Ideas:

    http://www.digitaltonic.co.uk/2009/09/03/wordpress-postpage-attributes-meta-box-missing/

    Thread Starter Devin Price

    (@downstairsdev)

    Phew. Thanks for the suggestion.

    Forum: Plugins
    In reply to: Sorting Pages by Category
    Thread Starter Devin Price

    (@downstairsdev)

    Thanks for the amazing support on this MichaelH. It was more than expected and fully appreciated.

    I explored several more plug-ins and decided Flutter might be a better approach for what I was wanting to do (and simpler for a novice coder). But for Kyle, and anyone else looking for a solution to this problem, try this code:

    <?php if (is_page('your-page-to-display-cat-id-2')) { ?>
    
    <?php
    if (function_exists('mpc_get_categories')) {
      $mpc_cats=MPC_CATEGORIES;
      $mpc_page_cats=MPC_PAGES_CATEGORIES;
    
      $cats = mpc_get_categories();
    
    //Will display a list of the categories so you know which ids they have
      echo '<!--';
      print_r($cats);
      echo '-->';
    
      /*
      SELECT post_id FROM wp_mpc_pages_categories
      WHERE category_id IN ('4')
      LIMIT 0,4
      */
    
      //get category id
      //This uses 2 because I want posts from cat 2 to show on this page
      $category_id = 2;
    
      //build query
      $querystr = sprintf("SELECT post_id FROM %s
        		   		   WHERE category_id IN ('%s')
        		   		   LIMIT 0,4", $mpc_page_cats, $category_id);
    
      //get result
      $catpageids = $wpdb->get_col($querystr,0);
    
      var_dump($catpageids);
    
      //do we have a result?
      if ( $catpageids ) {
    
      	// let's assume $catpageids is an array
    	$pageposts = get_pages(array(
    		'include' => implode(',', $catpageids)
    	));
    
      	/*
        $args = array(
          'post_in' => $catpageids,
    	  'post_type' => 'page'
    	);
    
    	//http://codex.ww.wp.xz.cn/Template_Tags/get_posts
        $pageposts = get_posts($args);
    	*/
      }
    }
    ?>
    
    <?php if ($pageposts): ?>
      <?php foreach ($pageposts as $post): ?>
        <?php setup_postdata($post); ?>
    
        <div class="post" id="post-<?php the_ID(); ?>">
          <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>">
          <?php the_title(); ?></a></h2>
          <small><?php the_time('F jS, Y') ?> <!-- by <?php the_author() ?> --></small>
          <div class="entry">
             <?php the_content('Read the rest of this entry »'); ?>
          </div>
    
    				<p class="postmetadata"><?php the_tags('Tags: ', ', ', '<br />'); ?> | <?php edit_post_link('Edit', '', ' | '); ?>  <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?></p>
        </div>
      <?php endforeach; ?>
    
      <?php else : ?>
        <h2 class="center">Not Found</h2>
        <p class="center">Sorry, but you are looking for something that isn't here.</p>
        <?php //include (TEMPLATEPATH . "/searchform.php"); ?>
     <?php endif; ?>
    
    <?php } ?>

    Give a specific example of what you would like to do or a site you would like to emulate.

    Thread Starter Devin Price

    (@downstairsdev)

    Nevermind. Another podcasting plug-in was interfering. Just cleared it up.

Viewing 15 replies - 466 through 480 (of 482 total)