WordPress.org

Ready to get started?Download WordPress

Forums

Feat image link to page url ?? (3 posts)

  1. boblebad
    Member
    Posted 1 year ago #

    Hi

    I'm trying to get a child theme working, and are having promblems with function.php, and getting teatured image to link to the page url ..

    <?php
    function hent_pages(){
    
    	$args = array(
    		'sort_order' => 'ASC',
    		'post_type' => 'page',
    		'sort_column' => 'menu_order'
    	);
    
    	$pages = get_pages($args);
    
    	foreach ($pages as $page) {
    		if($page->post_parent == 0){
                            echo '<div class="polaroid">';
    
    			//echo $page->post_title . "<br>";
    
                            $feat_image = wp_get_attachment_url( get_post_thumbnail_id($page->ID) );
    			echo '<div class="polaroidimage"><a href="" rel="bookmark"><img src="'.$feat_image.'"></a>';
    			echo '<div class="polaroidtitle">hej<br></div>';
                            echo '</div></div>';
    
    		}
    	}
    }
    ?>

    It's the a href i need to transform into php, and i can't figure out how to do it, maybe i've bin sitting to many hours behind the screen, so i'm not thinking that clear anymore ;-)

    Thanks

  2. s_ha_dum
    Member
    Posted 1 year ago #

    echo '<div class="polaroidimage"><a href="'.get_permalink($page->ID).'" rel="bookmark"><img src="'.$feat_image.'"></a>';
  3. boblebad
    Member
    Posted 1 year ago #

    Thanks you very much :)

    Thought that it had something to do with the page id, but was told that i couldn't use get_permalink ..

Topic Closed

This topic has been closed to new replies.

About this Topic