WordPress Development Asked by prakashchhetri on December 10, 2021
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
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 )
Answered by vancoder on December 10, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP