Viewing 6 replies - 1 through 6 (of 6 total)
  • I don’t understand the page you’re linking to. Can you explain what you want to achieve?

    Thread Starter Bjorn van der Neut

    (@neutcomp)

    An admin functionality where you can add “school pages” with name/telephone/address information. And then on the website an next -> previous option and an filter option that you can search for lets say “ABC School”.

    Ah, I see. For this you can simply use Pages in WP. Make a Page template called e.g. schoolgrid.php in your templates folder with this code:

    <?php
    /* Template Name: Schools Grid */
    ?>
    
    <?php get_header(); ?>
    
    <div id="content">
    <?php
    if($post->post_parent):
    $thispage = get_post($post->ID);
    $pagelist = get_pages('sort_column=post_title&sort_order=asc&child_of='.$post->post_parent);
    $pages = array();
    foreach ($pagelist as $page) {
       $pages[] += $page->ID;
    }
    
    $current = array_search($post->ID, $pages);
    $prevID = $pages[$current-1];
    $nextID = $pages[$current+1];
    ?>
    
    <div class="navigation">
    <?php if (!empty($prevID)) { ?>
    <div class="alignleft">
    <a href="<?php echo get_permalink($prevID); ?>"
      title="<?php echo get_the_title($prevID); ?>">Previous</a>
    </div>
    <?php }
    if (!empty($nextID)) { ?>
    <div class="alignright">
    <a href="<?php echo get_permalink($nextID); ?>"
     title="<?php echo get_the_title($nextID); ?>">Next</a>
    </div>
    <?php
    } 
    
    	setup_postdata($thispage);
    	echo '<h2>'.get_the_title().'</h2>';
    	the_content();
    else:
    	$schoolgrid = get_pages('child_of='.$post->ID.'sort_order=post_title');
    	if($schoolgrid){
    		echo '<ul>';
    		foreach($schoolgrid as $school):
    			echo '<li><a href="'.get_permalink($school->ID).'">'.$school->post_title.'</a></li>';
    		endforeach;
    		echo '</ul>';
    	}
    endif;
    ?>
    </div>
    
    <?php get_footer(); ?>

    Modify the template to fit your needs.

    Make a Page called e.g. «Schools» and employ the template on it (no need to enter content, as it will automatically make a list of its sub-pages). Make a sub-page for each school, where «Schools» is the parent, and make sure you employ the template on these, too. This should work. On the Page «Schools» you get an unordered list sorted alphabetically, with links to each school. Each school-page will have next/previous links on top.

    Thread Starter Bjorn van der Neut

    (@neutcomp)

    Thanks! It works but I do not get the next – previous links.
    I cannot find also how many items there must be to show it?

    I have 17 items on the page now.
    http://www.rsspage.net/?page_id=5

    Hope you can help me out on this point!

    I see the next – previous links on your page, they work fine as far as I can see.

    I guess the the listing will default to the number of posts set in Settings > Reading. You can override this by changing:

    $schoolgrid = get_pages('child_of='.$post->ID.'sort_order=post_title');

    to

    $schoolgrid = get_pages('child_of='.$post->ID.'sort_order=post_title&number=999');

    It will then show 999 pages.

    Thread Starter Bjorn van der Neut

    (@neutcomp)

    Thanks! And have a happy new year!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Looking for an grid plugin’ is closed to new replies.