1

I am creating a wordpress CMS and I have added multiple pages under one parent page. I am generating the links for all the child pages of a page and then when user clicks on the links, they should be able to open the child page. How ever when I click on the links, the index page is opened and no child page content is displayed. May be it is due to the use of the .htaccess file. I dont have any knowledge of htaccess. Any help?

<?php
            $pages = get_pages( array( 'child_of' => $post->ID, 'sort_column' => 'post_date', 'sort_order' => 'desc' ) );

            foreach ($pages as $page) {
            ?>

                <div class="contentarea">
                <div class="leftside"><img alt="" src="http://zom.jtechsolutions.co/wp-content/themes/zone/images/pic_1.jpg" /></div>
                <div class="rightside">
                <h2><?php echo $page->post_title; ?></h2>
                <?php echo substr(strip_tags($page->post_content),0,50); ?>

                <a href="<?php echo get_post_permalink($page->ID); ?>">Read More...</a>

                </div>
                </div>

            <?php

                }
            ?>  

.htaccess

 # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>

# END WordPress
5
  • Can you post a link to the problem page?
    – s_ha_dum
    Feb 27, 2013 at 23:44
  • @s_ha_dum zom.jtechsolutions.co/services Feb 27, 2013 at 23:53
  • Those links look right. Unfortunately your theme is not using body_class so I can't tell what template is loading.
    – s_ha_dum
    Feb 28, 2013 at 0:16
  • What's your permalink structure?
    – jfacemyer
    Feb 28, 2013 at 4:01
  • The clue will be inspecting the URLs as HTML then copy pasting them into a browser. If they look well-formed but go to the wrong page there’s a permalink problem, if the links are not well formed there’s a PHP problem. If the latter then print_r everything in sight.
    – Chris Pink
    Mar 24, 2021 at 20:25

1 Answer 1

0

According to the codex, get_post_permalink applies to custom post types. I don't think you are using a custom post type, right?

Instead, try get_page_link( $page->ID )

3
  • 1
    I used it, it is not working either. zom.jtechsolutions.co/services this is the link Feb 28, 2013 at 0:02
  • 1
    Your links are correct. htaccess is correct. There's something else awry. Have you perhaps edited your page.php to be the home page?
    – vancoder
    Feb 28, 2013 at 0:11
  • Are you using Apache or NGINX? Links may be related to your site setup in NGINX. Aug 6, 2022 at 11:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.