analogpanda
Forum Replies Created
-
Forum: Fixing WordPress
In reply to: show sub page content on a parent pageBased on the code posted by krusch, here’s what I ended up with:
<?php $pages = get_pages('child_of='.$post->ID.'&sort_column=post_date&sort_order=desc&parent='.$post->ID); foreach($pages as $page) { ?> <div class="section" id="<?php echo $page->post_name; ?>"> <h4><a href="<?php echo get_page_link($page->ID) ?>"><?php echo $page->post_title ?></a></h4> <?php echo apply_filters('the_content', $page->post_content); ?> </div> <?php } ?>
The code from krusch stopped after 2 items, so I removed that logic.
I also changed the class on the wrapping div to “section” rather than “feature_product” since it made more sense in the context of my particular usage (but it’s semantically generic enough for general use). I also added an id to the wrapping div – this id is based on the ‘URL slug’ by using ‘$page->post_name’.Also notice that I changed the H2 to an H4 (only because it made sense in the context of my usage), but please also notice that the code from krusch wraps an anchor (‘a’) element around the H2 which is invalid HTML, so I instead wrapped the H2 (H4 in my case) around the anchor.
As krusch suggests, you can also call the content which I originally did using just
$page->post_content
. That worked, but it needed formatting, so I ran it through theapply_filters()
function like so: apply_filters(‘the_content’, $page->post_content);Hope this helps. And to answer mortocks’ question – yes, this code is added to page.php
Forum: Fixing WordPress
In reply to: Problem with “current_page_item” navigation highlightingmunzli’s fix worked for me (thanks, munzli!)
I had this problem in version 2.2 and still have it in 2.3.1
I’ll check the trac and report this bug if it hasn’t yet been reported
Forum: Fixing WordPress
In reply to: Problem with “current_page_item” navigation highlightingIt also seems that setting the “Front page” and “Posts page” in wpAdmin -> Options -> Reading has broken the proper functionality of the is_home() and is_page() functions.
(wp ver 2.2.1)
Since I’ve set up my front page as: example.com and my posts page as example.com/blog, is_home() evaluates to true when I’m at example.com/blog, and I can’t get is_page() to work at all now.
Can anyone confirm this?
Perhaps I’m just too sleepy and tired, so I’ll double check this in the morning to make sure…
Forum: Themes and Templates
In reply to: customising wp_list_pagesJust for completeness, my above hack was done with WP 2.2.1
Let’s hope that 2.3 (or even 2.2.2?) has a little more flexibility in this regard.
I’m actually a little surprised they wouldn’t just use “the loop” – would probably end up with a more elegant solution than my hacky method… But I’m not a real php dev – maybe they have their reasons!
Forum: Themes and Templates
In reply to: customising wp_list_pagesI wanted to do this too, and couldn’t find any information on it.
In the end, I had to edit the start_el() function in wp-includes/classes.php
Change the following (from about line 517):
$output .= $indent . '<li class="' . $css_class . '"><a href="' . get_page_link($page->ID) . '" title="' . attribute_escape(apply_filters('the_title', $page->post_title)) . '">' . apply_filters('the_title', $page->post_title) . '</a>';
To this:
$output .= $indent . '<li class="' . $css_class . '"><a href="' . get_page_link($page->ID) . '" title="' . attribute_escape(apply_filters('the_title', $page->post_title)) . '"><span>' . apply_filters('the_title', $page->post_title) . '</span></a>';
Of course, this will always add span tags any time wp_list_pages is called. And you’ll have to remember that you’ve done this hack the next time you upgrade…