WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] Individual post pages custom content

[Resolved] Individual post pages custom content

  • Apologies if this has already been answered elsewhere, but I haven’t been able to turn up anything yet.

    I’m using WP as a CMS for a website I’m working on (still locally, nothing online to show as yet!). I’m displaying posts on a page called ‘news’ (that’s all working fine) but I want to add some additional HTML to the pages where the individual posts are shown.

    Basically, all I want to do is to link back to the ‘news’ page from the child pages (the individual posts). But I obviously don’t want the link to appear on the parent page (the news page).

    I’ve found a (seemingly working) function to find sub-pages:

    function is_subpage() {
     global $post; // load details about this page
     if ( is_page() && $post->post_parent ) { // test to see if the page has a parent
          	$parentID = $post->post_parent; // the ID of the parent is this
            return $parentID; // return the ID
    	} else { // there is no parent so...
          	return false; // ...the answer to the question is false
    };
    };

    But have not been able to get it to work – I’ve tried using the following code:

    <?php if(is_subpage('news')) : ?>
    <p><a href="<?php bloginfo('url') ?>/news/">Read all news stories</a></p>
    <?php endif; ?>

    Any help greatly appreciated!

Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘[Resolved] Individual post pages custom content’ is closed to new replies.