the code below that is set to pick up different cathegories. How can I change it to only search for category id=81 for example?
you did not post any relevant code where this might happen;
consider to post the full code of the template – possibly use the pastebin; see http://codex.ww.wp.xz.cn/Forum_Welcome#Posting_Code
Thank you!
I try to be more clear! I use a theme that has severeal sections on the frontpage. One section is called: Two Column Mini Slideshow Loop.
I want this to repeat twice, but if I only copy this code: http://pastebin.com/CndxTCW7, I will get the same categorys repeating. So I thought if I can write the php-code in a way that it only get one category I can work this out. The other way, to get it to work in the admin of the theme, is to advanced for me. I am still a beginner.
/Karin
The categories used in your code snippet are contained in $data['home2cols_slide_col1_cat'] and $data['home2cols_slide_col2_cat']. The values appear to come from your theme admin settings, this is where you should be setting the categories desired, it should not be that advanced a skill.
To answer your question, replacing every occurrence of those variables with the string (or integer as appropriate) value of the desired category ID will result in a slideshow in each loop limited to the specified category ID.
For example, for category 81 to be used in the first loop. replace every occurrence of $data['home2cols_slide_col1_cat'] with '81' or 81 as appropriate, in lines 13 and 14:
$home2cols_slide_col1_cat = '&cat=' . '81';
$thecat = get_category(81);
Thank you for your response. I can add categories for the two columns that are in the theme admin from start. But I don´t know how to add kolumn three and four to the theme admin. Is this easy? I thought this was complicated?
Do you know I guide to learn this?
It is not complicated, but getting the CSS right can be a challenge sometimes. It is probably not possible from the admin screens, otherwise the method would have been obvious. To get 4 columns you can simply repeat the same code, but change the categories used as I indicated previously. Of course in this case you cannot use the admin settings for categories. You will also need to change the class names in the HTML elements.
This will yield 4 different lists of content, but the appearance on the page will probably not be to your liking. Changing the appearance involves possibly altering the CSS of the existing columns. And certainly adding new CSS for the new columns. Depending on how the existing content CSS works, this can be easy or difficult.
If you have trouble adapting the existing CSS, a different approach would be to find an example 4 column layout you like on the Web. There are many CSS examples for all sorts of layouts. Alter your HTML output and CSS file to match the example. This is more complicated, but possible if you proceed carefully and keep backups of the original files in case things do not go well.
Thank you very much for you guide! I managed to copy the code and work with the css. There is only one problem left that I cant solve.
This is the url to the page:http://www.poppet.se/
at the end of the page you see the columns. When doing what you suggested I get the right header above but the images are from the sama category. Did I miss something?
/Karin
Apparently 🙂
Each column has a separate call to query_posts(). The category ID parameter for the last column needs to be changed, it is apparently the same as the previous column.
Similarly, the <h3> line just before also needs to be edited to reflect the different category and corresponding link.
I managed to change the <h3> line. But were do I change the category in this code /<?php query_posts( “post_type=post” . $home2cols_slide_col2_cat . $home2cols_slide_col2_limit ); ?>/
I tried to use the code you gave me before like this: /<?php query_posts( “post_type=post” . $home2cols_slide_col2_cat= ‘&cat=’ . ’81’;
$thecat = get_category(81); ?>/
… but that doesn´t work.. Do I miss something?
Yeah, there’s a syntax issue there. It’s my fault, I changed strategies on you between posts, apologies. This should work for you:
<?php query_posts( 'post_type=post&cat=81' . $home2cols_slide_col2_limit ); ?>
I sort of changed strategies yet again by running together the fixed string portions, simplifying so it’s more clear what’s really happening.
This makes anything in the code you copied that is related to $home2cols_slide_col2_cat irrelevant. Other than being slightly less efficient, it doesn’t hurt anything. Once this is all resolved and working correctly, if you’re feeling adventurous, try commenting out the irrelevant portions. If you can do that without breaking anything, it would be safe to delete the commented text. Still, keep backups just in case 🙂
Thank you very much for all the help! Now everything works perfectly! I guess commenting out irrelevant code is a great way to learn!
/Karin
You are most welcome.
My thought exactly for a learning opportunity. Have fun!