0

My site has a static front page and a blog.

I'm using the Foundation5 grid and I've split the content of the homepage onto three rows, like this, and I'm updating both the content and the html in the text-editor.

<page content 1st row>
<page content 2nd row>
<page content 3rd row>

My problem is that I want to split the first headline into two blocks. The one on the left is my page content and the one on the right should display the most recent blog headline + some other infos. Like this:

<page content 1st row><blog headline>
<page content 2nd row--------------->
<page content 3rd row--------------->

http://neverbland.com/ has a nice example of what I'm talking about (scroll to the very bottom of the page, the yellow block on the right).

Normally I would create a custom page template but in this case the php code would be right in the middle of my page content so I thought I'd use a plugin.

I downloaded and customized the Flexible posts widget to display the most recent post in a widget and then amr shortcode any widget to insert the widget as a shortcode in the middle of the page content (Flexible Posts Widget doesn't support shortcodes yet).

It works, but I'm using two plugins and I'm editing a few files just to display one headline, I'm wondering if there's a better approach. I'm sure I'm missing something. (I'm using the http://jointswp.com/ theme btw)

0

Since you add all the html in the post by hand, have you tried filtering the content?

Similar to WordPress's <!--more--> tag, you could just add <!--my_headline_content-->

Then:

add_filter( 'the_content', 'my_headline_function_12378' );

function my_headline_function_12378( $post_content ){

    /* 
     * get your recent posts' data. You'll find the code with a simple search.
     * say $headline contains the headline html (link, addnl info, whatever)
     * swap your tag with this headline
     */
    $the_content = preg_replace( '/<!--my_headline_content-->/i', $headline, $the_content );

    return $the_content;

}

Done.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.