GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   Wordpress, php, and css question (help me please) (https://gfy.com/showthread.php?t=973989)

tonyparra 06-17-2010 09:13 PM

Wordpress, php, and css question (help me please)
 
Hello. Im trying to style the wp_list_categories tag (<?php

wp_list_categories('arg'); ?>). i know that i can style it using an unordered list and css. Something like this:

<ul class="cat_list"><?php

wp_list_categories('show_count=1&hide_empty=1&titl e_li=<h2>Categories</

h2>'); ?></ul>

That will print a list of categories, hide categories with zero post, and show title called "categories". What i would like to do though is make the parent category links look different from the child category links (have a different font size or use <h3> tag for parent category), so i how would i do that? Like i said I know how to style whole list but how can I make this customization happen? Or is it not possible? Thanks for any help. :)

tonyparra 06-17-2010 09:44 PM

bumperoo

mattz 06-17-2010 09:56 PM

bump for ya

harvey 06-17-2010 10:08 PM

well, I don't have an example with categories and subcategories at hand (oh my, why in hell every single person asking for help NEVER includes the example so they can actually be helped?) but if you constructed it using defaults you should have something like

Code:

<ul>
<li>Cat 1</li>
<li>Cat2
    <ul>
          <li> Cat 2 Children category </li>
    </ul>
</li>
</ul>

where
Code:

<li> Cat 2 Children category </li>
will have a class named .children or .child or something like that (don't remember right now, and since nobody post examples.... :Oh crap). Just style that class and you'll be done

tonyparra 06-18-2010 07:05 AM

Quote:

Originally Posted by harvey (Post 17259039)
well, I don't have an example with categories and subcategories at hand (oh my, why in hell every single person asking for help NEVER includes the example so they can actually be helped?) but if you constructed it using defaults you should have something like

Code:

<ul>
<li>Cat 1</li>
<li>Cat2
    <ul>
          <li> Cat 2 Children category </li>
    </ul>
</li>
</ul>

where
Code:

<li> Cat 2 Children category </li>
will have a class named .children or .child or something like that (don't remember right now, and since nobody post examples.... :Oh crap). Just style that class and you'll be done


sorry i was tired when i made thread...the wp_list_categories prints your category list heres a snippet of code from the default wordpress theme sidebar:
Code:

<?php wp_list_categories('show_count=1&title_li=<h2>Categories</h2>'); ?>
that will print a list in alphabetical order with child categories, and post count. An example of what i currently have can be found in the default wp theme, an example of what i would like my list to look like can be found here:
http://www.hotmovies.com/categories.php
The parent cats are bold and using the <h3> tag, therefore helping to show the difference between parent and child cats. Is that possible in wordpress?

tonyparra 06-18-2010 07:36 AM

bump for me :)

cyber 06-18-2010 07:52 AM

Code:

$sql = "SELECT name,slug,$wpdb->terms.term_id as ID,parent FROM $wpdb->terms ".
      "LEFT JOIN $wpdb->term_taxonomy ON ($wpdb->terms.term_id = $wpdb->term_taxonomy.term_id) ".
      "WHERE parent=5 AND taxonomy='category' ORDER BY name ASC";
$categoryList = $wpdb->get_results($sql);

echo categoryPrint($categoryList);



function categoryPrint($results, $multiple = "", $subcat_level = 0){
  global $wpdb;
  if(!$results){return;}
  foreach($results as $a_cat){
    if($multiple){
      categoryPrintSelectItem($a_cat, $subcat_level);
    }
    else{
      categoryPrintItem($a_cat, $subcat_level);
    }
    $sql = "SELECT name,slug,$wpdb->terms.term_id as ID,parent FROM $wpdb->terms ".
          "LEFT JOIN $wpdb->term_taxonomy ON ($wpdb->terms.term_id = $wpdb->term_taxonomy.term_id) ".
          "WHERE parent=$a_cat->ID AND taxonomy='category' ORDER BY name ASC";
    $sub_cats = $wpdb->get_results($sql);
    categoryPrint($sub_cats, $multiple, $subcat_level + 1);
  }
}
function categoryPrintSelectItem($a_cat, $subcat_level){
  for($i = 0; $i < $subcat_level; $i++){
    echo "…";
  }
  echo $a_cat->name."</option>\n";
}
function categoryPrintItem($a_cat, $subcat_level){
  for($i = 0; $i < $subcat_level; $i++){
    echo "{$a_cat->name}<br>";
  }
  if($subcat_level < 1){
    echo "<b><h3>{$a_cat->name}</h3></b><br>";
  }
}

Change this:

Code:

WHERE parent=5
To the category's ID.

fris 06-18-2010 08:24 AM

Quote:

Originally Posted by cyber (Post 17260053)
Code:

$sql = "SELECT name,slug,$wpdb->terms.term_id as ID,parent FROM $wpdb->terms ".
      "LEFT JOIN $wpdb->term_taxonomy ON ($wpdb->terms.term_id = $wpdb->term_taxonomy.term_id) ".
      "WHERE parent=5 AND taxonomy='category' ORDER BY name ASC";
$categoryList = $wpdb->get_results($sql);

echo categoryPrint($categoryList);



function categoryPrint($results, $multiple = "", $subcat_level = 0){
  global $wpdb;
  if(!$results){return;}
  foreach($results as $a_cat){
    if($multiple){
      categoryPrintSelectItem($a_cat, $subcat_level);
    }
    else{
      categoryPrintItem($a_cat, $subcat_level);
    }
    $sql = "SELECT name,slug,$wpdb->terms.term_id as ID,parent FROM $wpdb->terms ".
          "LEFT JOIN $wpdb->term_taxonomy ON ($wpdb->terms.term_id = $wpdb->term_taxonomy.term_id) ".
          "WHERE parent=$a_cat->ID AND taxonomy='category' ORDER BY name ASC";
    $sub_cats = $wpdb->get_results($sql);
    categoryPrint($sub_cats, $multiple, $subcat_level + 1);
  }
}
function categoryPrintSelectItem($a_cat, $subcat_level){
  for($i = 0; $i < $subcat_level; $i++){
    echo "?";
  }
  echo $a_cat->name."</option>\n";
}
function categoryPrintItem($a_cat, $subcat_level){
  for($i = 0; $i < $subcat_level; $i++){
    echo "{$a_cat->name}<br>";
  }
  if($subcat_level < 1){
    echo "<b><h3>{$a_cat->name}</h3></b><br>";
  }
}

Change this:

Code:

WHERE parent=5
To the category's ID.

thats a sure messy way to do it, when you can do it with css.

have a look at the default wordpress css styling, theirs one for child cats.

http://digwp.com/2010/05/default-wor...-styles-hooks/

cyber 06-18-2010 08:36 AM

Quote:

Originally Posted by fris (Post 17260236)
thats a sure messy way to do it, when you can do it with css.

have a look at the default wordpress css styling, theirs one for child cats.

http://digwp.com/2010/05/default-wor...-styles-hooks/

I repurposed to code from a page of mine that prints out the categories in form select fields for something totally different.

Figured this would get the job done without telling him what CSS styles he needed to change ;)

tonyparra 06-18-2010 10:32 AM

Quote:

Originally Posted by fris (Post 17260236)
thats a sure messy way to do it, when you can do it with css.

have a look at the default wordpress css styling, theirs one for child cats.

http://digwp.com/2010/05/default-wor...-styles-hooks/

hmm so are you saying style the child cats maybe i can bold the parents im having a hard time putting that together though can you help me out?

tonyparra 06-18-2010 12:00 PM

this may require custom solution it seems...

harvey 06-18-2010 02:07 PM

Quote:

Originally Posted by tonyparra (Post 17259924)
sorry i was tired when i made thread...the wp_list_categories prints your category list heres a snippet of code from the default wordpress theme sidebar:
Code:

<?php wp_list_categories('show_count=1&title_li=<h2>Categories</h2>'); ?>
that will print a list in alphabetical order with child categories, and post count. An example of what i currently have can be found in the default wp theme, an example of what i would like my list to look like can be found here:
http://www.hotmovies.com/categories.php
The parent cats are bold and using the <h3> tag, therefore helping to show the difference between parent and child cats. Is that possible in wordpress?

yes, I know you used that hook, I just shown you the output. So here you have since your code is outputting something different to what it should be (not your fault, probably a change in WP, you're using the correct function as documented):

Code:

<?php $sub_cat =  wp_list_categories('echo=0&amp;orderby=name&amp;title_li=&amp;hierarchical=0&amp;child_of='.$category->cat_ID); ?>
        <ul class="subcat"><?php echo $sub_categories; ?></ul>
<?php } ?>


fris 06-18-2010 06:06 PM

hit me up on icq 704-299 ill see if i can sort you out

Deej 06-18-2010 06:15 PM

Watch out... I ICQ'd Fris once and all the sudden my dog died.

ICQ at your own risk...


All times are GMT -7. The time now is 11:05 PM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123