{"id":668,"date":"2013-06-14T07:46:18","date_gmt":"2013-06-14T14:46:18","guid":{"rendered":"http:\/\/10kdev.ivystreetinc.com\/?p=668"},"modified":"2013-06-14T07:46:18","modified_gmt":"2013-06-14T14:46:18","slug":"displaying-wordpress-post-parts","status":"publish","type":"post","link":"http:\/\/10kdev.net\/?p=668","title":{"rendered":"Displaying WordPress Post Parts"},"content":{"rendered":"<p>I switched this blog theme to &#8220;Photon&#8221; for a bit, very minimalist, \u00a0where I had 10 posts per page. \u00a0I just wanted to get some Google Analytic stats on specific article reads, and having full articles on a page doesn&#8217;t give that to me. \u00a0I needed\u00a0the articles to display like this on the navigational pages:<\/p>\n<ul>\n<li>Home Page \u00a0(Page 1)\n<ul>\n<li>Entire Recent Article<\/li>\n<li>First 128 character excerpt of next 9 articles.<\/li>\n<\/ul>\n<\/li>\n<li>Page 2\n<ul>\n<li>First 128 character excerpt\u00a0of next 10 articles.<\/li>\n<\/ul>\n<\/li>\n<li>Etc.<\/li>\n<\/ul>\n<p>So I had to adjust index.php from the WordPress editor, and here&#8217;s what I did:<\/p>\n<pre class=\"brush: php; light: true; title: ; notranslate\" title=\"\">\r\n&lt;?php get_header(); ?&gt;\r\n\r\n&lt;?php get_sidebar(); ?&gt;\r\n\r\n&lt;div id=&quot;wrapper&quot;&gt;\r\n\r\n&lt;!-- $posts defaults to 10 but you can change it--&gt;\r\n&lt;?php \/*$posts = get_posts('numberposts=10');*\/ ?&gt;\r\n\r\n&lt;div id=&quot;posts&quot; class=&quot;excerpts&quot;&gt;\r\n\r\n&lt;ul&gt;\r\n\r\n&lt;!-- this section sets the length of the preview for older articles, using a WP filter --&gt;\r\n&lt;?php\r\n $firstElement = 0;\r\n function custom_excerpt_length( $length ) {\r\n return 128;\r\n }\r\n add_filter( 'excerpt_length', 'custom_excerpt_length', 999 );\r\n ?&gt;\r\n &lt;?php foreach ($posts as $post) : ?&gt;\r\n\r\n&lt;?php setup_postdata ($post); ?&gt;\r\n\r\n&lt;!-- this specifies what hyperlinks show up in the title position --&gt;\r\n &lt;li&gt;&lt;h2 class=&quot;post-title&quot;&gt;&lt;a href=&quot;&lt;?php the_permalink (); ?&gt;&quot;&gt;&lt;?php the_title(); ?&gt;&lt;\/a&gt;&lt;\/h2&gt;\r\n &lt;small&gt;&lt;?php the_time('F jS, Y') ?&gt; by &lt;?php the_author() ?&gt;&lt;\/small&gt;\r\n\r\n&lt;!-- reset the data query or there will be defects in the behavior --&gt;\r\n&lt;?php wp_reset_query(); ?&gt;\r\n\r\n&lt;!-- make sure the post is first one on first page, if so show all of it, else you just get a excerpt--&gt;\r\n &lt;?php if (get_option ('photon_index_post_length') == &quot;full&quot; &amp;&amp; $firstElement == 0 &amp;&amp; is_home() &amp;&amp; '1' &gt; $paged ) : ?&gt;\r\n\r\n&lt;?php the_content (); ?&gt;\r\n\r\n&lt;?php else: ?&gt;\r\n\r\n&lt;?php the_excerpt (); ?&gt;\r\n\r\n&lt;?php endif; ?&gt;\r\n\r\n &lt;p class=&quot;postmetadata&quot;&gt;\r\n Posted in &lt;?php the_category(', ') ?&gt;\r\n &lt;strong&gt;|&lt;\/strong&gt;\r\n &lt;?php edit_post_link('Edit','','&lt;strong&gt; |&lt;\/strong&gt;'); ?&gt;\r\n &lt;?php comments_popup_link('No Comments \u00bb', '1 Comment \u00bb', '% Comments \u00bb'); ?&gt;&lt;\/p&gt;\r\n\r\n&lt;?php $firstElement++; \/* bil *\/ ?&gt;\r\n &lt;\/li&gt;\r\n\r\n&lt;?php endforeach; ?&gt;\r\n\r\n&lt;li&gt;\r\n &lt;p style=&quot;float: left&quot;&gt;&lt;?php previous_posts_link(); ?&gt;&lt;\/p&gt;\r\n &lt;p style=&quot;float: right&quot;&gt;&lt;?php next_posts_link(); ?&gt;&lt;\/p&gt;\r\n &lt;p style=&quot;clear: both&quot;&gt;&amp;nbsp;&lt;\/p&gt;\r\n &lt;\/li&gt;\r\n\r\n&lt;\/ul&gt;\r\n\r\n&lt;\/div&gt;\r\n\r\n&lt;\/div&gt;\r\n\r\n&lt;?php get_footer(); ?&gt;\r\n\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>I switched this blog theme to &#8220;Photon&#8221; for a bit, very minimalist, \u00a0where I had 10 posts per page. \u00a0I just wanted to get some Google Analytic stats on specific article reads, and having full articles on a page doesn&#8217;t give that to me. \u00a0I needed\u00a0the articles to display like this on the navigational pages: [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"http:\/\/10kdev.net\/index.php?rest_route=\/wp\/v2\/posts\/668"}],"collection":[{"href":"http:\/\/10kdev.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/10kdev.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/10kdev.net\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/10kdev.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=668"}],"version-history":[{"count":5,"href":"http:\/\/10kdev.net\/index.php?rest_route=\/wp\/v2\/posts\/668\/revisions"}],"predecessor-version":[{"id":673,"href":"http:\/\/10kdev.net\/index.php?rest_route=\/wp\/v2\/posts\/668\/revisions\/673"}],"wp:attachment":[{"href":"http:\/\/10kdev.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=668"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/10kdev.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=668"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/10kdev.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=668"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}