• Resolved syncbox

    (@syncbox)


    I am using the following to insert the last 3 sub-pages of a parent page into that parent page… this is all working and I managed to figure out how to pull in the custom field data as well.

    Here’s what I’m using:

    <?php
    	$pages = get_pages('child_of=3&sort_column=menu_order&sort_order=ASC');
    	$count = 0;
    	foreach($pages as $page)
    	{
    		$cpimage = get_post_meta($page->ID,'cpimg',true);
    		$cpitalic = get_post_meta($page->ID,'cptagline',true);
    		$cpbrief = get_post_meta($page->ID,'cpdescription',true);
    		$content = $page->post_content;
    		if(!$content)
    			continue;
    		if($count >= 3)
    			break;
    		$count++;
    	?>
    
    <!--START A NEW CURRENT PROJECT BOX -->
    
    <div class="cp_slidebox">
    <h2 class="cptitle"><a href="<?php echo get_page_link($page->ID) ?>"><?php echo $page->post_title ?></a></h2>
    <div class="cpslide">
    <a href=""><img src="https://folio2010.syncbox.com/wp-content/uploads/<?php echo $cpimage ?>" alt="<?php echo $page->post_title ?> | Click to view slideshow" /></a>
    <p class="viewmore">
    <a href="<?php echo get_page_link($page->ID) ?>">View More</a>
    </p>
    </div>
    <h2 class="cptag"><?php echo $cpitalic ?></h2>
    <p class="cpdesc"><?php echo $cpbrief ?></p>
    
    <p class="postmetadata"><br /><br /><?php edit_post_link('Edit Current Project Content ↑', '', ''); ?></p>
    </div>
    
    <!--END THIS CURRENT PROJECT -->
    	<?php
    	}
    ?>

    BUT

    The above bit: <p class=”cpdesc”><?php echo $cpbrief ?></p> isn’t showing the class of the paragraph being written around the data of $cpbrief — It’s writing a paragraph, but without the class attribute.

    Oddly enough, the line above, writing the heading, DOES write the class (cptag) into the <h2> tag???

    What’s up with that? Your ideas greatly appreciated!

Viewing 1 replies (of 1 total)
  • Thread Starter syncbox

    (@syncbox)

    Figure this out… I had html markup in the custom field data, which affected things… nothing to do with the function at all.

    But I ended up changing my function, just in case anyone builds off of it… to pass the correct page ID to the get_post_link() function.

    That now looks like:

    <p class=”postmetadata”> <?php edit_post_link(‘Edit Current Project Content ↑’, ”, ”,$page->ID); ?></p>

Viewing 1 replies (of 1 total)
  • The topic ‘get_pages() and not writing a class attribute?’ is closed to new replies.