SitePoint Sponsor |
|
User Tag List
Results 1 to 13 of 13
-
Apr 10, 2008, 20:18 #1
- Join Date
- Oct 2006
- Location
- New Zealand
- Posts
- 2,323
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Custom Fields with WordPress Pages
Hi,
I'm having a devil of a time trying to figure out how to list some WordPress pages with associated Custom Fields. This is easy with posts, but I'm damned if I can figure out how to do it with WordPress pages.
So ... there would be a page, which would list all of the WordPress pages and beside each list item would be a code generated via the Custom Field of that page.
Any ideas on how to go about doing this?
-
Apr 10, 2008, 21:10 #2
Are you planning to add a dynamic code to all pages? I think you need a special script for this.
-
Apr 10, 2008, 22:28 #3
- Join Date
- Oct 2006
- Location
- New Zealand
- Posts
- 2,323
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Not to all pages, just to a specific page.
The page will display all the sub pages of that particular page. But the hard bit (or at least the part I can't figure out) is how to add information from a custom field from each page.
-
Apr 10, 2008, 23:04 #4
Will this assist you: http://codex.wordpress.org/Displayin...m_Select_Query
-
Apr 11, 2008, 00:58 #5
- Join Date
- Oct 2006
- Location
- New Zealand
- Posts
- 2,323
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
-
Apr 11, 2008, 09:47 #6
I am going through an identity crisis.
Glad that link was useful, I honestly did not understand what it was saying, well I sorta did but I am not the advanced user it referred to I guess.
-
Apr 12, 2008, 22:26 #7
- Join Date
- Mar 2006
- Posts
- 367
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I've never used this, but it looks like what you want
http://blog.ftwr.co.uk/wordpress/query-child-of-page/
adds an argument for query_posts
Edit: Couldn't you just query all your pages with query_posts('post_type=page') and add some conditional stuff in the loop for the custom field?Aaron
On Twitter
-
Apr 12, 2008, 22:49 #8
- Join Date
- Oct 2006
- Location
- New Zealand
- Posts
- 2,323
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
-
Apr 13, 2008, 00:39 #9
- Join Date
- Oct 2006
- Location
- New Zealand
- Posts
- 2,323
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Thanks aaronjj
I used your advice to track down the following forum post which solved my problem... http://wordpress.org/support/topic/155532?replies=3
-
Apr 15, 2008, 00:32 #10
- Join Date
- Oct 2006
- Location
- New Zealand
- Posts
- 2,323
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I thought this code did exactly what I was looking for. However I've now realised that it doesn't sort the page order according to the "WordPress Page Order", it generates them dependent on the date published.
Code:<?php $args = array( 'post_type' => 'page', 'numberposts' => 4, 'post_status' => 'publish', 'post_parent' => 7, // any parent ); $attachments = get_posts($args); //print_r("attachements:" . $attachements); if ($attachments) { foreach ($attachments as $post) { ?> <div class="feature-products-boximg" style="background:url('<?php $pictures = get_post_meta($post->ID, "image", true); echo $pictures; ?>');"> <a href="<?php the_permalink(); ?>"> <span><?php the_title(); ?></span> </a> </div> <?php $the_excerpt = get_post_meta( $post->ID, '1lineblurb', $single = true); if ($the_excerpt != '') { echo($the_excerpt); }// if: filename not blank } } ?>
Thanks
-
Apr 15, 2008, 15:00 #11
- Join Date
- Mar 2006
- Posts
- 367
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Add 'orderby' => 'menu_order' to your args
Aaron
On Twitter
-
Apr 15, 2008, 17:30 #12
- Join Date
- Oct 2006
- Location
- New Zealand
- Posts
- 2,323
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
-
Apr 15, 2008, 23:05 #13
- Join Date
- Oct 2006
- Location
- New Zealand
- Posts
- 2,323
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
That did the trick perfectly
Thanks aaronjj. Your help is much appreciated
Bookmarks