How can I force Wordpress post format?

Hi, I have an urgent request.

A theme I have for a client makes use of the Wordpress's post formats. My client's posts are in the Standard format. However, the format we have decided to go with is the Image format.

One big huge problem though, her previous post are not showing in standard format. The initial post link in the blogroll shows, but the single page post does not show it's content when visited. When I set that post to Image, everything shows as it should. I'm not sure of why, and even the new Wordpress 3.6. settings is set to Image format for default, but makes no difference.

We haven't went through all her blogs posts yet to make them the Image format as she wanted to rush the project launch.

Is there a quick function I can add to make all her posts force the Image format and ignore the other post formats?

Kind regards,

  • Ash
    • WordPress Hacker

    Hello Noahj

    I hope you are well today and thanks for asking the question.

    To force all post to have a post-format, you can do following things.

    1. If you are using <?php get_template_part( 'content', get_post_format() ); ?> change it to <?php get_template_part( 'content', 'image' ); ?>

    or

    2. You can manually set the post-format by this code:
    set_post_format($post->ID, 'image' );

    Hope it helps.

    Feel free to ask if you have any more question.

    Cheers
    Ash

  • Noahj Champion
    • Site Builder, Child of Zeus

    Hey Ash!
    set_post_format($post->ID, 'image' );
    did not work.

    My php code is more like this...
    <?php if(get_post_format() == "image")
    .... other content here then

    <?php }
    }else if(get_post_format() == "gallery"){ ?>

    Then other content here...

    And so on for post formats, Image, Gallery, Video, Audio, Quote,

    Kind regards Ash,

  • Ash
    • WordPress Hacker

    Assuming your code is like this:

    <?php
    if(get_post_format() == "image") {
      //some code for image
    }
    else if(get_post_format() == "gallery"){
      //some code for gallery
    }
    else if(get_post_format() == "aside"){
      //some code for aside
    }.......
    ?>

    Try replacing with just

    <?php
      //some code for image
    ?>

    That means you will remove all condition and just put one block of codes that processes for image post format.

    Hope it helps.

    Cheers
    Ash

  • Noahj Champion
    • Site Builder, Child of Zeus

    Hey, I appreciate your help, but I was able to just charge my client for redoing all their blog posts.

    I tried the solution above and didn't get it to work, but I'm sure it was just my misplacing of the code a bit.

    I may come back to this back to this though later on and spend more time to try this out.I'm sure your code solution works because it makes sense.

    Best regards Ashok,

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.