如何获得wordpress页面图标和永久链接标题

如何获得wordpress页面图标和永久链接标题

问题描述:

hello evryone i am new on wordpress. and m facing a problem that, i want to access all my child page title and their icon image (which are uploaded in page icon) in a page. i also get the title of pages but permalink and icon image is hard to get me. please... please help me.my code is here

<div class="vwt_single_blog_box_tab">
<?php if ( is_page() ) { 
    if($post->post_parent)
    {       
            $id = $post->post_parent; 
    }
        else
    {
            $id = $post->ID; 
    }
     //$children = wp_list_pages('title_li=&child_of='.$id.'&echo=0');
    $args = array(
        'sort_order' => 'ASC',
        'sort_column' => 'post_title',
        'hierarchical' => 1,
        'exclude' => '',
        'include' => '',
        'meta_key' => '',
        'meta_value' => '',
        'authors' => '',
        'child_of' => 1,
        'parent' => $id,
        'exclude_tree' => '',
        'number' => '',
        'offset' => 0,
        'post_type' => 'page',
        'post_status' => 'publish'
    ); 
    $pages = get_pages($args);      

    ?>      
    <ul>
        <?php
        foreach($pages as $page)
        {           
        ?>
         <li>
        <div class="software-part">
            <div class="soft-part">
            <?php echo get_the_post_thumbnail( $page->ID, 'thumbnail' ); ?>
            <h1><?php echo apply_filters( 'the_title', $page->post_title, $page->ID ); ?></h1>
            <?php echo apply_filters( 'the_content', $page->post_content ); ?>
                <div class="software-part-right">
                <h2><?php echo $page->post_title; ?></h2>
                </div>
                <p><?php $page->post_content = get_the_content();
                $page->post_content = strip_tags($page->post_content);
                    echo substr($page->post_content, 0, 100); ?>
                </p>
            </div>
        </div>
         </li>


        <?php
        }
        ?>  
   </ul>
    <?php
}
?>                


</div>   

`

thank you.

This should do the trick:

<div class="vwt_single_blog_box_tab">
<?php if ( is_page() ) { 
    if($post->post_parent)
    {       
            $id = $post->post_parent; 
    }
        else
    {
            $id = $post->ID; 
    }
     //$children = wp_list_pages('title_li=&child_of='.$id.'&echo=0');
    $args = array(
        'sort_order' => 'ASC',
        'sort_column' => 'post_title',
        'hierarchical' => 1,
        'exclude' => '',
        'include' => '',
        'meta_key' => '',
        'meta_value' => '',
        'authors' => '',
        'child_of' => 1,
        'parent' => $id,
        'exclude_tree' => '',
        'number' => '',
        'offset' => 0,
        'post_type' => 'page',
        'post_status' => 'publish'
    ); 
    $pages = get_pages($args);      

    ?>      
    <ul>
        <?php
        foreach($pages as $page)
        {           
        ?>
         <li>
        <div class="software-part">
            <div class="soft-part">
            <?php echo get_the_post_thumbnail( $page->ID, 'thumbnail' ); ?>
            <h1><a href="<?php echo get_permalink( $page->ID ); ?>"><?php echo get_the_title( $page->ID ); ?> </a></h1>
        </div>
         </li>


        <?php
        }
        ?>  
   </ul>
    <?php
}
?>                


</div>

You were calling the permalink and title in the wrong way. For that use get_permalink() and for title get_the_title();

I've tested the output and it's working.

PS - There's no such thing as Icon. What you want is a thumbnail that can be a featured image or not.