David H
Forum Replies Created
-
Forum: Fixing WordPress
In reply to: Parent children in sidebarDrawing on what you have here, @jasoncamp, in combination with the information listed in the Get Pages Function Reference page in the Codex, here’s another solution. (See wp list pages in the Codex for more on its parameters, including the ability to exclude specific pages.)
<?php if($post->post_parent) { // if the current page has a parent $parent_title = get_the_title($post->post_parent); $parent_link = get_permalink($post->post_parent); $children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0");?> <ul> <li><?php echo "<a href='" . $parent_link . "'>" . $parent_title . " Main</a>"; ?> </li> <?php } else { // if the current page is the parent $parent_title = get_the_title($post->ID); $parent_link = get_permalink($post->ID); $children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0"); ?> <ul> <li class="current_page_item"><a href="#"><?php the_title(); ?> Main</a> </li> <?php } echo $children; ?> </ul>
Forum: Themes and Templates
In reply to: Custom page template for Posts pageFor anyone else who’s having a similar issue, I was experiencing the same thing vkhavin was above but I figured out the following. It’s a bit of a hack, but I’m not offended.
I had created a page called Home and a custom template called home.php, which I customized to fit my homepage needs. In the Admin Page area, I had used the template attribute to associate the Home page with a custom template called home.php. Using Settings_Reading I made Home my static homepage, and also made another page I had created, called Blog, my page for posts. The problem was that no matter what custom template I associated with the Blog page, it would still show the home.php template, which contained the customizations I had made for the homepage. According to my understanding of the Template Hierarchy, a custom template blog.php should have taken highest priority, overriding any default settings, but it didn’t.
Eventually what worked was changing home.php to homepage.php and deleting home.php from the server. After that, the page Blog that I had created (/blog/) still didn’t draw from the blog.php template page (or any other custom template I tried), but it did use the index.php template, which worked for me.
If, under Settings_Reading, I didn’t set the page Blog to be the Posts page then it would just work as a normal content page, receiving any custom template I chose. So, the issue seems to be with the setting of any page to be the Posts page. Trying the About page as the Posts page confirms this.