scdwb
Forum Replies Created
-
Forum: Fixing WordPress
In reply to: If posts in one category are also in another category?!Thanks Michael,
That will come in handy for the widgets, I haven’t come across that before. Brilliant.
But I dont think that will work for the original thing I am trying to do as that is for displaying the posts. I am making progress though from the code I wrote below.
It queries the posts in the category variable “$city” and then displays the company logo if a post from the $city category is also in “Company Name” category.
This works almost! The problem is if 10 posts are in both categories then 10 logos appear. Is it possible to only display the logo once? Basically ill be having many if statements for about 10 companies. If 1 or even 100 posts belong to a company I only want the logo to show once
<?php query_posts("cat=$city");?> <?php while (have_posts()) : the_post(); ?> <?php if ( in_category( 'Company Name' )) { ?><img src="<?php bloginfo('template_directory'); ?>/images/logos/Company-Name.png" /> <?php } ?> <?php endwhile; ?>
thanks for your help!
Forum: Fixing WordPress
In reply to: If posts in one category are also in another category?!The in_category tag will not work for this, or at least not in the form you are meant to use it.
As how would I call the category (I have it in a variable) and then see whether any posts in this category also belong in another category?
In_category would probably be used somewhere, but I don’t know how. Can you help?
It would be great to have the raw code. So I could even create a widget to show posts that are in 2 particular categories.
I have a property website with properties both in a City category and in a Letting Company category.
So I would like to be able to show posts (which are property listings) that are in City X from Company X.
Thanks
Forum: Plugins
In reply to: Display categories of post (separately(!?))Ah ha, I figured it out. I’ll be an expert before I know it.
<?php foreach((get_the_category()) as $childcat) { if (cat_is_ancestor_of(1, $childcat)) { $selected= $childcat->cat_ID;}} wp_dropdown_categories("class=large&selected=".$selected.""); ?>
Forum: Plugins
In reply to: Display categories of post (separately(!?))I am trying to use the above solution in another part of my website. But in this case I don’t need to echo the $childcat->cat_name;. I would like to store it in a variable.
I am using wp_dropdown_categories() and would like child category of my specified parent category to be selected. The code below works almost perfectly. But it still has the echo in and is echoing the cat_id on my page.
What can I do to remove the echo and just store $childcat->cat_ID; instead?
<?php foreach((get_the_category()) as $childcat) { if (cat_is_ancestor_of(1, $childcat)) { echo $childcat->cat_ID; $currentcity = $childcat->cat_ID;}} ?> <?php wp_dropdown_categories("selected=".$currentcity.""); ?>
Thanks Guys
Forum: Plugins
In reply to: Display categories of post (separately(!?))Hi Esmi,
I was using custom fields for this but I decided to do it this way to kill two birds with 1 stone. As it really increases the speed of adding posts.
I managed to find a solution.
<?php foreach((get_the_category()) as $childcat) { if (cat_is_ancestor_of(1, $childcat)) { echo $childcat->cat_name;}}
Im a newbie to PHP but as I see it this code is getting all the category names assigned to the post and for each of these is storing it in the $childcat variable.
Then if a category is assigned to the “ancestor of category id 1” then this category name is displayed.
This is great as I just change the top level category id (cat_is_ancestor_of(CAT_1, &childcat)).
Forum: Fixing WordPress
In reply to: wp_dropdown_categories problem – Show roots URLCan anyone help me out with this?
Thanks
Forum: Fixing WordPress
In reply to: Almost there, can you help?The above method is too complex for my php knowledge. So I decided to handle it in the theme page itself:
<?php $company = get_post_meta($post->ID, "companies_value", true); ?>
Then repeat these if statements to show the image if that company is selected.
<?php if ($company == "Company 1") { ?> <img src="<?php bloginfo('template_directory'); ?>/images/Company1.png"/> <?php } ?>
Forum: Fixing WordPress
In reply to: “IF template name is this then do this” …in PHP :-)By the way, this is the code:
<?php if ( is_page_template('about.php') ) { // Returns true when 'about.php' is being used. } else { // Returns false when 'about.php' is not being used. } ?>
Forum: Installing WordPress
In reply to: Something very strange – changes are not saved!I ended up reinstalling wordpress and the problem disappeared. It will remain a mystery…
Thanks, how come it is just this one website though? All other wordpress installs on sites on the same server are working fine.
Cheers
Forum: Plugins
In reply to: [Plugin: WP-Table Reloaded] Second row have the same options as first rowThanks Tobias! But it’s not working for me, though it should be so easy…
I have tried a few variations. Here’s my CSS for the table and where I have put it in bold. I tried both these on their own and they don’t work for some reason. Can you tell me where and what to put? :-S
Thanks!
/* general table styles */
table.wp-table-reloaded {
font-family:arial;
background-color: #CDCDCD;
margin:10px 0pt 15px;
font-size: 8pt;
width: 100%;
text-align: left;
}/* Styles for the tablehead (<th>) (if enabled) */
table.wp-table-reloaded thead tr th, table.wp-table-reloaded tfoot tr th {
background-color: #7BBC08;
border: 1px solid #FFF;
font-size: 8pt;
padding: 4px;
color:#009999;
text-align: left;
font-size: 14px;
font-weight: bold;
color: #FFFFFF;
margin: 0px 0px 0px 0px;
border: 0px 0px 0px 0px;
padding: 7px 7px 7px 17px;}
table.wp-table-reloaded thead tr .header {
background-image: url(/wp-content/plugins/wp-table-reloaded/img/bg.gif);
background-repeat: no-repeat;
background-position: center right;
cursor: pointer;
}table.wp-table-reloaded tbody td {
color: #3D3D3D;
padding: 4px;
background-color: #FFF;
vertical-align: top;
}table.wp-table-reloaded-id-1 .row-2 {background-color:#D6FB91;}
wp-table-reloaded-id-1 .row-2 {background-color:#D6FB91;}table.wp-table-reloaded tbody td.first {
color: #3D3D3D;
padding: 4px;
background-color: #D6FB91;
vertical-align: top;
font-size:18px;
}/* Styles for alternating row colors (if enabled) */
table.wp-table-reloaded tbody tr.even td {
background-color:#FFFFFF;
}
table.wp-table-reloaded tbody tr.odd td {
background-color:#F0F0F6;
}Forum: Fixing WordPress
In reply to: “IF template name is this then do this” …in PHP :-)Thanks Michael,
I did look, promise.
Forum: Fixing WordPress
In reply to: Really annoying if wordpress doesn’t do this…That’s great, thanks esmi,
I used:
#footermenu li:after
{
content: “|”;
}and it works great!
A tag in wordpress which puts it outside the
<a>
would be better though!Forum: Fixing WordPress
In reply to: Javascript file added to header.php but not workingCan any help with this? ??