WordPress.org

Ready to get started?Download WordPress

Forums

Defining Child Pages Using Custom Field & Output as Boxes (3 posts)

  1. klj
    Member
    Posted 1 year ago #

    Afternoon All.

    I am currently developing a new site for my company and I've used WordPress for many years as I find it very flexible and it tends to be adaptable to most situations I need. I have on this project hit a snag.

    The site is:

    http://37.26.106.20/~globestk/products/

    What I am trying to achieve is to be able to enter page id's into a custom field in the CMS and then have those pages displayed as boxes which the user can click on to go to a list of products very much similar to an ecommerce website.

    The company only sells to distributers and not to Jo Public so an ecommerce site wasn't really needed which is why I used WordPress.

    Has anyone come across a Plugin or code that gives this kind of functionailty? I am a designer rather than a coder which is why I am having difficulties. I can get it to list the id's I need but it then goes farther and lists all the other pages on the site.

    My code for this page is:

    <?php
    
    	/*
    		Template Name: Category Page
    	*/
    
    ?>
    
    <?php get_header(); the_post(); ?>
    
    <div id="content">
    
    <?php
    
    		echo "<div class='category_box'>";
    
    		query_posts("posts_per_page=-1&post_type=page&post_parent=$pieces");
    
    		while (have_posts()) : the_post(); ?>
    
    		<a href="<?php the_permalink(); ?>" class="categories" title="<?php the_title(); ?>">
    
            <div class="category_name">
            	<h2><?php the_title(); ?></h2>
            </div><!-- end .category_name -->
    
    		<div class="category_image">
              	<?php echo "<img src='" . get_post_meta($post->ID, "image", true) . "' />"; ?>
            </div><!-- end . category_image -->
    
            </a>
    
    		<?php endwhile; wp_reset_query();
    
    		echo "</div>";
    
    	?>
    
    </div><!-- end #content -->
    
    <?php get_sidebar(); ?>
    
    <?php get_footer(); ?>

    Any help or suggestions would be gratefully received.

    Thanks

    Kev

  2. codingpet
    Member
    Posted 1 year ago #

    query_posts("posts_per_page=-1&post_type=page&post_parent=$pieces");

    This is the custom query you wrote. The query is incorrect because all pages will be selected and display.

    For products, I suggest you use custom post type on http://codex.wordpress.org/Post_Types Create a custom posts type e.g. products to manage all products will be better.

    If you don't want to check codes, this plugin maybe helpful.
    http://wordpress.org/extend/plugins/custom-post-type-ui/

  3. klj
    Member
    Posted 1 year ago #

    Hi codingpet.com

    Thanks for the suggestions. Will give them a go and see how I get on. New to coding but eager to learn.

    Many Thanks

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.