• Resolved nathanmwalters

    (@nathanmwalters)


    Hi everyone.

    I’m building a new text-based website in the Twenty-Eleven theme, and I’m taking the long view as to what will be added to the site in the future. The site is primarily a blog, but, eventually (two years at the earlier), I will want to use the front page for e-commerce (while I keep adding to the blog). In the meantime, I need content for the front page.

    I don’t wish to confuse my blog’s readers (and their links) by, in two years, moving all the blogposts from the front page, http://www.mypage.nob/, to http://www.mypage.nob/blog. I have already created http://www.mypage.nob/blog. I have set the front page to “static,” and I have designated the aforementioned blog page as such. I then created a http://www.mypage.nob/home, went into customize, and set the front page as http://www.mypage.nob/home. So far, so good. Blog posts appear on the blog page. The content I add to http://www.mypage.nob/home appears on the front page (there currently is no content “at home” except for the page name, “home,” which I would like to eliminate.)

    This is where I wander into work far above my paygrade.

    As mentioned above, I need content for the front page. My fantasy is as follows:

    • I want to embed an exact duplicate of the “latest post,” its full version, from start to finish, on the front page.

    • I put up a new post every Tuesday and Thursday. When a new post is published, I would like the code controlling all of this to recognize that there is a new “latest post” and replace the older one — and that’s replace, not add. I only want one post on the front page.

    ( I am using the follow permalink format: http://www.mypage.nob/2015/11/30/title-slug/ )

    • I’d like the title of the embedded post to be the same size as a “normal title” on the blog page and centered, but I would settle for centered and at least a few points larger than the body of the post’s text. Heck. I’d settle for four points bigger flush right.

    • I am using Jetpack comments and sharing. I am also using Social Login, Social Sharing by miniOrange 4.7 (found here).

    • In my fantasy, I would like functionality of each of these three plugins to follow the embedded post (so that comments appear on the blog post and not in the comment section of the home page).

    In my la-la land, I would be able to embed all of that onto the front page so that it looked all but identical to the individual post’s page (i.e., the individual page of the post being embedded). Below that, I’d add an html hyperlink to the blog page so that readers would know where to go to read more, but that’s the one thing here that I actually know how to do.

    And, while I’m dreaming, in this perfect world of mine, I would love to add tabs or buttons to allow coding in the Jetpack comment field rather than forcing the commenter to add her or his own markdown text. I’d prefer WYSIWYG, but I’d settle for markdown buttons or tabs (similar to this message box).

    Thank you for reading my message. I know it’s long, but I wanted to make sure and include all the relevant information that I could think of.

    I am now ready to be the target of supreme lulz.

    Thanks,
    Nathan

Viewing 7 replies - 1 through 7 (of 7 total)
  • I use a plugin called xili Post in Post. On one of the sites that I maintain, I use it to display the latest post from a particular category of posts. Once nice feature is that you can include different parameters within the shortcode to add elements which makes it easier to style the post using CSS. For example, here’s the shortcode that I use to display that latest post on the home page:

    [xilipostinpost query="cat=9" showposts=1 showcontent=1 showexcerpt=0 beforetitle='<h2>' aftertitle="</h2><br />" beforeall="<span id='MMTitle'>Sensei's Monthly Message</span>" afterall="" beforecontent='<div class="xi_postinpost_content">' aftercontent='</div>']

    Every time a new post is created in that category, it automatically replaces the previous one because the plugin displays the latest post by default.

    I wasn’t sure about your last requirement, but the social media and comment functionality will not show up on the post displayed using the plugin.

    Thread Starter nathanmwalters

    (@nathanmwalters)

    Thanks for your reply and suggestion. I monkeyed around a bit with the plugin before reading your example code and I’m confident that I can pull up the needed post(s) by replacing “cat=9” with “?”

    Again, I’m using the sharing function built into Jetpack, and, so far, I have been seeing the sharing options.

    But here’s the thing: all of my posts include “<!–more–>”, and that is all that I can mangage to get xili Post in Post to display. Depending how I configure it, I either the excerpt or the text before “<!–more–>”, and below the text (i.e., the post’s first paragraph), I either get “more” or “continue reading,” which send me to the original post page. Is there a way to show an entire post if it’s “broken” with “<!–more–>”.

    I appreciate your directing me to this plugin. It will come in handy even if it doesn’t solve this particular problem.

    Thanks!
    Nathan

    I’ve never noticed that before, I guess because I don’t usually use the <!--more--> tag.

    I dug into the plugin’s code, and it looks like a simple fix. The plugin calls the_content() function to retrieve the post contents, and according to the Codex, if you set the $more global variable to 1, you should get the entire post instead of just the part above the <!--more--> tag.

    If you go into the plugin editor and edit xili-postinpost/xili-postinpost.php, look for these lines:

    if ( $showcontent )
    	$postinpostresult .= $beforecontent.apply_filters('the_content',get_the_content( $r['more'] )).$aftercontent;
    // $r['more'] => $more is a WP global variable !!!

    Change it to this:

    if ( $showcontent )
    {	// add this opening bracket
    	$curr_more = $more;	// save the current value of the $more variable
    	$more = 1;	// set $more to 1 to show all post content
    	$postinpostresult .= $beforecontent.apply_filters('the_content',get_the_content( $r['more'] )).$aftercontent;
    // $r['more'] => $more is a WP global variable !!!
    	$more = $curr_more;	// reset $more back to original value
    }	// close bracket

    I’ve added // comments to the end of every line that I’ve added to make it easier to see my changes. Now the entire post should be displayed.

    Thread Starter nathanmwalters

    (@nathanmwalters)

    Brilliant!

    That worked perfectly. I appreciate your taking the time to find a solution and break it down for the luddite who is I.

    Thanks!
    Nathan

    Thanks SO much for this.. this helped me as well..EXCEPT.. that the problem with this is that if we overide the MORE tag in th epost in post this way.. ti actually overides <MORE> in blog archive page as well.. not just the single post page…

    How could we edit the code so it was as above, but modified as follows:

    if (I AM IN SINGLE PAGE) ..

    if ( $showcontent )
    { // add this opening bracket
    $curr_more = $more; // save the current value of the $more variable
    $more = 1; // set $more to 1 to show all post content
    $postinpostresult .= $beforecontent.apply_filters(‘the_content’,get_the_content( $r[‘more’] )).$aftercontent;
    // $r[‘more’] => $more is a WP global variable !!!
    $more = $curr_more; // reset $more back to original value
    } // close bracket

    To demo what I mean, please see this page: http://27.121.66.4/~abab6919/wordpress/pigmentation/

    This is a post that uses post in a post, and it is clipping it at the READ MORE … If I add the code given above, it will make the full, post work .. but then at the summary page.. where I need short grabs (up to the MORE tag) to be used it used the full post instead..

    I really just need to know hwp to modify the above code so that it eitjer:

    A – if specific only to single full post pages..

    OR ..

    B – is specific to certain full post pages.. IE I target them by their post ID .. (As I only have a few instances where I need to use Post i a Post

    Thanks SOOO much! 🙂

    Kirstie, you should be able to use the is_single() function. Try something like this:

    if ( $showcontent )
    {	// add this opening bracket
    	if (is_single())	// is this a single post page?
    	{
    		$curr_more = $more;	// save the current value of the $more variable
    		$more = 1;	// set $more to 1 to show all post content
    	}
    	$postinpostresult .= $beforecontent.apply_filters('the_content',get_the_content( $r['more'] )).$aftercontent;
    // $r['more'] => $more is a WP global variable !!!
    	if (is_single())	// is this a single post page?
    	{
    		$more = $curr_more;	// reset $more back to original value
    	}
    }	// close bracket

    As noted in the codex, you can also add a specific post ID in the function call if you want to limit the full post to just a specific post page.

    Worked perfectly .. thanks SOOO .. I am very grateful!

    i am sure this will be really useful to others as well.. because if you are using the <MORE> function then this would mean you have a summary and would need the code modification to to specify the single page like.

    Thanks again! 🙂

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Can I embed the full text of a blog post on a static front page?’ is closed to new replies.