Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #6936

    I haven t tried yet so I want to ask first if this is possible.

    Instead of the portfolio area on the hompage example I need instead to have the same area but have it pull content from a category. For example I have a events category and a news category. I need to have the last 4 posts from those two categories to shows just like with the Portfolio category.

    Is this doable? I am talking about the part with 4 images in a row linking to individual posts.

    Or am I stuck with using php to call these categories? I was hoping I could add a new Element to the Template builder so that instead of having only Portfolio to pick I could have one Element called Category and then have content pulled from that category. I am sure others would be interested in this as it adds a lot of functionality to the template builder

    #55955

    Could I duplicate loop-portfolio and then change it so that it does not call the Portfolio but a category? i am going through the code now but I am not that familiar with the avia framework…I am sure it should not be that complicated to change the call from being done to the portfolio and swap it to a category

    #55956

    Maybe the solution is to add a related posts section to the homepage template…4colums and have that call a particular category.

    What do you think? This is a dealbreaker for me since I absolutely need to show News and Events the same way the portfolio area on the homepage is showing them.

    #55957

    Hey,

    I’m not sure but I think the easiest way is to duplicate the loop-portfolio.php

    You can replace following line:

    if(isset($avia_config['new_query'])) { query_posts($avia_config['new_query']); }

    with custom query code or (even better solution) you can create a new template based on template-portfolio.php and adjust the query there:

    if(!isset($avia_config['new_query']['tax_query'][0]['terms'][0]) || $avia_config['new_query']['tax_query'][0]['terms'][0] == "null")
    {
    if(!isset($avia_config['portfolio_item_count'])) $avia_config['portfolio_item_count'] = '-1';

    $avia_config['new_query'] = array("paged" => get_query_var( 'paged' ), "posts_per_page" => $avia_config['portfolio_item_count'], "post_type"=>"portfolio");
    }

    I.e. you can replace the tax_query with a standard post/page query, etc.

    #55958

    Thank you so much for your time. The code above works great to pull the last 8 posts in chronological order. I haven t touched template-portfolio.php since I won t be using the portfolio on the site.

    With the above code I still need a little help. I know your time is valuable so no rush if you have more pressing forums questions to answer.

    - The image preview is not picked up. I made sure that each posts has a Featured image but the code above does not seem enough in loop-portfolio.php to pick the image as well for some reason. I guess the category “portfolio” may be hard coded somewhere.

    - Could you help me with what exact query I could use to for example only show the last 4 posts in the category “News”. I m a novice with php. Ideally I would need it to show something like 2×4 columns first one being from category X and the second being from category Y. I guess making two loops one after each other would be fine.

    Thanks in advance

    #55959

    Maybe you need to delete the query in template-portfolio.php or overwrite it in loop-portfolio.php – that’s something you need to test. I’d use a query like:

    $avia_config['new_query'] = array("paged" => get_query_var( 'paged' ),  "posts_per_page" => "8",  "post_type"=>"post", "category_name" => "News");

    instead of:

    if(!isset($avia_config['new_query']['tax_query'][0]['terms'][0]) || $avia_config['new_query']['tax_query'][0]['terms'][0] == "null")
    {
    if(!isset($avia_config['portfolio_item_count'])) $avia_config['portfolio_item_count'] = '-1';

    $avia_config['new_query'] = array("paged" => get_query_var( 'paged' ), "posts_per_page" => $avia_config['portfolio_item_count'], "post_type"=>"portfolio");
    }

    in template-portfolio.php. You can also use:

    "cat" => "ID"

    instead of:

    "category_name" => "News"

Viewing 6 posts - 1 through 6 (of 6 total)

The topic ‘Instead of portfolio on homepage use a category’ is closed to new replies.