Forums

"Static" Home Plus Content From "Edit Page" CMS (2 posts)

  1. charvan
    Member
    Posted 2 weeks ago #

    Static home page setup.

    Calling the loop and the titles of the 10 most recent blog posts within a div.

    Have another div where I would very much like to pump text from the page being used as static from within admin/pages/edit/*pagename* so that that site editors are able to update content in said div without having to use admin/appearance/editor or the PHP file itself.

    Does this require and additional instance of The Loop? My attempts have provided screwy results (PHP novice) - both additional Loop and within same instance of Loop.

    Guessing there is a simple an appropriate PHP call to make this happen but having a devil of a time conceiving of it.

    Thank you for reading. Will grovel for responses.

  2. charvan
    Member
    Posted 2 weeks ago #

    Have this working, but trying to understand why and also if it will stand up to use.

    <!--Loop-->
    <?php if (have_posts()) : ?>
    <?php while (have_posts()) : the_post(); ?>
    
    <?php global $post; $myposts = get_posts('numberposts=5&category=1'); foreach($myposts as $post) : ?>
    <div <?php post_class() ?> id="post-<?php the_ID(); ?>"><h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2></div>
    
    <?php endforeach; ?>
    <?php endwhile; ?>
    <?php endif; ?>
    <!--Loop-->
    
    <!--MiniLoop (actual new query without loop?)-->
    <?php global $post; $myposts = get_posts('numberposts=1&category=1'); foreach($myposts as $post) : ?>
    <?php the_content(); ?>
    <?php endforeach; ?>
    <!--MiniLoop (actual new query without loop?)-->

    What I cannot seem to grok is how both of these are referring to the global list of posts and getting different results -

    • Loop pulling the first 5 entries from the "blog" page
    • "MiniLoop" pulling from the text I have entered via the CMS from the page being called and used as Home NOT from post entries

    Additionally for MiniLoop:

    • - if "numberposts" is anything but "1" it pulls the text form the CMS entry page the same number of times (repeats it over and over)
    • - "Pages" don't have "Categories", why is "category=1" grabbing the copy as explained above?

Reply

You must log in to post.

About this Topic

Tags