• So I noticed that our JSON file was not collecting the posts’ summary or featured image with items.summary or items.image. I didn’t bother trying to code for them, seeing that they weren’t even in the JSON file itself. (attached below is my code)

    Is there a way to have the JSON pull this data in so that I can include it in my feed?

    <article class="band darkGreyBG feeder" style="background-image: url('/images/flag-capitol-bw-sm.jpg');">
    	<div class="overlay darkGreyGradient"></div>
    
    	<div class="wrap">
    		<h2 class="greenT">Recent Posts About Green Cards</h2>
    
    		<ul class="feedList"></ul>
    
    		<a class="feedButton button gold radius dropShadow noMin caps normWeight" target="_blank">View All Posts</a>
    	</div>
    
    	<script type="text/javascript">
    		$(document).ready(function() {
    			$.get('https://learn.simplecitizen.com/category/live-in-usa/green-card/feed/json', function(data) {
    				var items = data.items;
    
    				$('a.feedButton').attr('href', data.feed_url);
    				$('a.feedButton').attr('href', function(u, url) {
    					var str = url.substring(url.lastIndexOf('/feed/') + 1);
    					return url.replace( new RegExp(str), '' );
    				});
    
    				for (var i = 0; i<=items.length; i++) {
    					var item = items[i];
    						date = new Date(item.date_published);
    						titleDiv = document.createElement('div');
    						titleDiv.innerHTML = item.title;;
    						title = titleDiv.textContent || titleDiv.innerText;
    						bodyDiv = document.createElement('div');
    						bodyDiv.innerHTML = item.content_html;;
    						summary = bodyDiv.textContent || bodyDiv.innerText;
    					
    					if(summary.length > 100) summary = summary.substring(0,100);
    
    					// console.log(item);
    
    				 	$('ul.feedList').append('<li class=""><a href="' + item.url + '" target="_blank"><span class="postTitle greenT w400">' + title + '</span><span class="postSummary marTop20 w300">' + summary + '&hellip;</span><span class="postExtras marTop20"><span class="w700"><i class="fa fa-calendar-o greenT" aria-hidden="true"></i>&nbsp;&nbsp;' + date.toDateString() + '</span><span class="w700"><i class="fa fa-user greenT" aria-hidden="true"></i>&nbsp;&nbsp;' + item.author.name + '</span></a></li>');
    				}
    			});
    		});
    	</script>
    </article>
  • The topic ‘Posts’ summaries and featured images not showing in JSON file’ is closed to new replies.