Display excerpt in Custom Post Type
-
Hi Everyone,
I have a problem displaying the excerpt of a custom post type that is driving me nuts!
I have registered the excerpt in the custom post using supports as follows: –
'supports' => array( 'title', 'editor', 'excerpt', 'author', 'thumbnail', 'custom-fields', 'revisions', 'page-attributes' ),
This shows the excerpt in the admin interface.
The trouble is when I use get_the_excerpt() I don’t seem to get anything. I know it is there, because it’s in the admin area and others things are showing it, but when I write specific code to include it, nothing, in fact it breaks the map I am supposed to be showing it in. At the moment my code for the map bubble is: –<?php $title = get_the_title(); $excerpt = get_the_excerpt(); $content = get_the_content(); $permalink = get_the_permalink(); ?> ['<?php echo("<div style=\"width:400px;height:160px;\">".the_post_thumbnail( 'thumbnail', array( 'class' => 'map-bubble-align' ) )."<div><a href=\"".$permalink."\" ><h2>".get_the_title()."</h2></a><p>".$excerpt." </p><a href=\"".$permalink."\"<p>Read More...</p></a></div></div>"); ?>', <?php echo $location['lat']; ?>, <?php echo $location['lng'];?>, <?php $NUM++ ?>],
The thumbnail, permalink and title are all fine, but the excerpt and content don’t load and usually stop the map from loading. I have also tried using get_the_excerpt() directly rather than via a variable and that doesn’t work either.
The page on the site where I have this is currently https://www.brenclosures.com.au/projects-locations.htm btw if you want to have a look.
Any ideas anyone? I am totally at a loss. I have tried everything I can think of but am getting nowhere!
Thanks
- The topic ‘Display excerpt in Custom Post Type’ is closed to new replies.