• Resolved iavinash

    (@iavinash)


    Hello All,

    It seems that the latest version of the theme can display the post in standard blog style. My question is will it be possible to select it for specific category only.

    For Example: I do not want to display the standard blog style on my front page but when select a menu (category Job) it should display all the posts/jobs in standard blog style.

    Hope i am clear.

    Thanks,
    Avinash

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hi iavinash. Copy archive.php to your child theme and change the first line after have_posts() to this:

    <?php if ( have_posts() ) : ?>
    
      <?php if ( ot_get_option('blog-standard') == 'on'  ||  is_category( 'Job' ) ): ?>

    If the Standard Blog option is On, it will display all categories in that format. If it is Off, only the “Job” category will use that format.

    Thread Starter iavinash

    (@iavinash)

    Thanks bdbrown,

    I will try this and let you know. One small clarification though. What if i need to use it for more than one but not for all categories. Should it look like this

    <?php if ( have_posts() ) : ?>
    
      <?php if ( ot_get_option('blog-standard') == 'off'  ||  is_category( 'Job' ) ||  is_category( 'recipe' ) ||  is_category( 'article' ) ): ?>

    Thank you
    Avinash

    Use the array format:

    <?php if ( ot_get_option('blog-standard') == 'on' || is_category( array( 'Job', 'recipe', 'article' ) ) );

    Codex Function Reference/is_category

    Hi iavinash. Just a point of clarification. When I stated:

    If the Standard Blog option is On, it will display all categories in that format. If it is Off, only the “Job” category will use that format.

    I was referring to the Theme Options > Blog > Standard Blog List option, not the option test in the php “if” statement. The way you have the php test now:

    ( ot_get_option('blog-standard') == 'off'

    means that if you have the Theme Option set to Off, that part of the “if” test is true so every page will use the standard blog layout, which I don’t think is what you’re after. The php option test should still be:

    ( ot_get_option('blog-standard') == 'on'

    This way you can control the rest of the site using the Theme Option. When you turn the Theme Option On, that part of the “if” test is true so it will apply the standard blog layout to all pages. If you set the Theme Option to Off, that part of the “if” test will fail, so it checks the next part of the “if” test. If the page is one of the categories you specify, that part of the “if” test will be true so it will use the standard blog layout for that category. If it’s not one of the categories you specify, then both parts of the “if” test are false, so the default content layout is used.
    Hope that makes sense and sorry for any confusion.

    Thread Starter iavinash

    (@iavinash)

    Thanks bdbrown,

    This worked as i was expecting. It seems there was a typo in the code and closing php tag was missing. I used it as follows and it worked.

    <?php if ( ot_get_option(‘blog-standard’) == ‘on’ || is_category( array( ‘Job’, ‘Recipe’, ‘Article’ ) ) ): ?>

    Thanks for your help and clear explanations.
    Avinash

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Standard blog style for specific category’ is closed to new replies.