WordPress.org

Ready to get started?Download WordPress

Forums

Using custom fields to show excerpt or full post content in homepage (9 posts)

  1. casidios
    Member
    Posted 2 years ago #

    Hi everyone. First, apologize for my english. I hope I can make you understand my problem.

    I'm using a pro-theme in my WordPress instalation (www.sexodrogasyvideojuegos.com). The template has the option to show full post content or the excerpt, but I want to mix them in it. I want to show the excerpt by default and use custom fields to show full post content in the homepage.

    I've seen several snippets of code, but I can't make it work. Someone could help me?

    Thanks in advance

  2. Digital Raindrops
    Member
    Posted 2 years ago #

    Can you post the name of the custom field, and the code from the file that renders the content or excerpt to http://pastebin.com

    David

  3. casidios
    Member
    Posted 2 years ago #

    I don't mind the name of the custom field. The code of the homepage.php of my blog is:

    <iframe src="http://pastebin.com/embed_iframe.php?i=PQRLd4yu" style="border:none;width:100%"></iframe>

  4. casidios
    Member
    Posted 2 years ago #

  5. Digital Raindrops
    Member
    Posted 2 years ago #

    There you go custom field name = excerpt !

    Look for /** EDIT in the text

    http://pastebin.com/CfTAstic

    EDIT UPDATED CODE:

    <?php if( !$excerpt || $unisphere_options['show_blog_full'] != '1') :

    Should be:

    <?php if( $excerpt || $unisphere_options['show_blog_full'] != '1') :

    So the edited lines are:

    <?php /** EDIT See if we want the Content or excerpt? */ ?>
            <?php
                    global $post;
                    $excerpt = get_metadata( $post->ID,'excerpt', true );
            ?>
            <?php /** EDIT added condition $excerpt below */ ?>
    
        <?php if( $excerpt || $unisphere_options['show_blog_full'] != '1') :
    // User has not checked the option to display full posts in the blog, so use the excerpt template... ?>

    If this is ok mark the post as resolved!

    HTH

    David

  6. casidios
    Member
    Posted 2 years ago #

    let's try it. So, I paste the code in my template?

    Thanks

  7. casidios
    Member
    Posted 2 years ago #

    So, i have to create a custom field called "excerpt" and ...

  8. Digital Raindrops
    Member
    Posted 2 years ago #

    So, i have to create a custom field called "excerpt" and ...

    1, true, yes anything apart from false or 0

    HTH

    David

  9. casidios
    Member
    Posted 2 years ago #

    Sorry, but it doesn't work. I can make it work, with some problems with de CSS that i have to manage, with this code:

    http://pastebin.com/hn9xGtSf

    It would be fine?

Topic Closed

This topic has been closed to new replies.

About this Topic