Forum Replies Created

Viewing 15 replies - 1 through 15 (of 22 total)
  • Thread Starter kreegah

    (@kreegah)

    Aight, takk for fiksing ??

    Thread Starter kreegah

    (@kreegah)

    Damn, I don’t remember what I did to fix it. But it’s now fixed. I reinstalled the plugin, and removed the feature details url – published. And then put the url back in.

    Thread Starter kreegah

    (@kreegah)

    The Feature Details URL are dead.

    Is there any other way to fix this?

    Thread Starter kreegah

    (@kreegah)

    Just to clarify vtxyzzy helped me fix my problem. posting the finalized code here if anyone else needs this kind of solution:

    // Custom CSS per Category and postname
    
    function my_enqueue_scripts() {
    
       wp_enqueue_style( 'style', get_stylesheet_uri(), '', '9.0', 'screen' );
    
    }
    
    add_action( 'wp_enqueue_scripts', 'my_enqueue_scripts' );
    
    function change_stylesheet_uri( $stylesheet_uri, $stylesheet_dir_uri ) {
    
       if ( is_single() ) {
    
          global $post;
    
          $term_list = get_the_term_list($post->ID,'product_categories');
    
       }
    
       if (strpos($term_list,'sitea') || is_tax( 'product_categories', 'grunnmur' ))
    
          $file =  $stylesheet_dir_uri .'/sitea.css';
    
       elseif (strpos($term_list,'gulv') || is_tax( 'product_categories', 'gulv' ))
    
          $file =  $stylesheet_dir_uri .'/gulv.css';
    
       elseif (strpos($term_list,'siteb') || is_tax( 'product_categories', 'vegg' ))
    
          $file =  $stylesheet_dir_uri .'/siteb.css';
    
       elseif (strpos($term_list,'sitec') || is_tax( 'product_categories', 'tak' ))
    
          $file =  $stylesheet_dir_uri .'/sitec.css';
    
       else
    
          $file =  $stylesheet_dir_uri . '/style.css'; // our default stylesheet
    
       return $file;
    
    }
    
    add_filter( 'stylesheet_uri', 'change_stylesheet_uri', 10, 2 );
    Thread Starter kreegah

    (@kreegah)

    You should have received a mail with the website in question so that you can see what the “issue” is. (i don’t want the url published on these forums)

    ??

    Thread Starter kreegah

    (@kreegah)

    my bad, I didn’t add a return

    But this doesnt force my products to use “grunn.css” if the product is listed in “grunnmur”, this will just override all the above code for every products to the set return stylesheet wouldn’t it?

    Thread Starter kreegah

    (@kreegah)

    outputs

    Parse error: syntax error, unexpected T_ELSE in line 31

    =/

    Thread Starter kreegah

    (@kreegah)

    So how do I go about to add this in addition to the code I already have?

    I was originally hoping that the earlier (resolved) code would be added to the products aswell, since they are in the different categories of `
    grunnmur, vegg and so on`

    Thread Starter kreegah

    (@kreegah)

    function change_stylesheet_uri( $stylesheet_uri, $stylesheet_dir_uri ) {
    
        if (is_tax( 'product_categories', 'grunnmur' ))
        	return $stylesheet_dir_uri .'/grunn.css'; 
    
        elseif (is_tax( 'product_categories', 'gulv' ))
        	return $stylesheet_dir_uri .'/gulv.css'; 
    
    	elseif (is_tax( 'product_categories', 'vegg' ))
       	return $stylesheet_dir_uri .'/vegg.css'; 
    
    	elseif (is_tax( 'product_categories', 'tak' ))
        	return $stylesheet_dir_uri .'/tak.css'; 
    
     	else
     		return $stylesheet_dir_uri . '/style.css'; // our default stylesheet
    
    }
    Thread Starter kreegah

    (@kreegah)

    I cheered to soon, the above works perfect for giving my product category different css. But I also have

    ?post_type=products

    to be viewed inside each category. How would I go by to add these into my custom css function.

    if (is_tax( 'product_categories', 'grunnmur' ))
        	return $stylesheet_dir_uri .'/grunn.css';
    // add to also be true in post_type=products&p=ID-OF-PAGES

    If you know how and got the time ??

    Thread Starter kreegah

    (@kreegah)

    Whooopie! You saved my day vtxyzzy!

    That worked flawlessly!

    (argh, to many functions for a non-coder to handle in this WP codex)

    Thanks a bunch, if you were close by I’d hug you!

    Thread Starter kreegah

    (@kreegah)

    Yeah, I’ve removed my variable.

    but unfortunately my code won’t work ??

    function change_stylesheet_uri( $stylesheet_uri, $stylesheet_dir_uri ) {
    
        if (term_exists( 'grunnmur' ))
        	return $stylesheet_dir_uri .'/grunn.css'; 
    
        elseif (term_exists( 'gulv' ))
        	return $stylesheet_dir_uri .'/gulv.css'; 
    
     	else
     		return $stylesheet_dir_uri . '/style.css'; // our default stylesheet
    
    }

    The really weird part is that my url shows

    /?taxonomy=product_categories&term=gulv

    and still the css for term_exists( 'grunnmur' ) loads in the whole page. not just for the product category “Grunnmur” as it should.

    Thread Starter kreegah

    (@kreegah)

    Yes, I’m sorry I am also confused, hehe. I’m not a coder at all.

    I got custom taxonomy = product_categories
    In product_categories i have child/subcategory/terms: gulv & grunn

    on my product page when viewing category “gulv” and its products I want it to load gulv.css, and then “grunn” to load grunn.css

    I get the css to load, but only for existing within product_categories, and not the “gulv” og “grunn” category

    I’ve fiddled some more and got this code now

    <?php
    $taxonomyname = "product_categories";
    ...
        if ( term_exists( 'grunn' ) )
        	return $stylesheet_dir_uri .'/grunn.css'; 
    
        elseif ( term_exists( 'gulv' ) )
        	return $stylesheet_dir_uri .'/gulv.css'; 
    
     	else
     		return $stylesheet_dir_uri . '/style.css'; // our default stylesheet
    
    }
    add_filter( 'stylesheet_uri', 'change_stylesheet_uri', 10, 2 );
    
    ?>

    [Moderator Note: Please post code or markup snippets between backticks or use the code button. As it stands, your code may now have been permanently damaged/corrupted by the forum’s parser.]

    Thread Starter kreegah

    (@kreegah)

    Child-taxonomy is my subcategory of my custom taxonomy

    ‘$taxonomyname = “product_categories”; // the custom_taxonomy
    $gulv = “15”; // the id of product_categories gulv (child)
    $grunn = “18”;’ // the id of product_categories grunn (child)

    WordPress still ignores and reads only the taxonomy, and not the ID i want to be found.

    Thread Starter kreegah

    (@kreegah)

    Thanks for your reply vtxyzzy, I found this out 5 minutes ago, but
    with my code, it still ignores my ID of child-taxonomy (18 and $gulv )

    if ( term_exists( 18, $taxonomyname ) )
    return $stylesheet_dir_uri .’/grunn.css’;

    elseif ( term_exists( $gulv, $taxonomyname ) )
    return $stylesheet_dir_uri .’/gulv.css’;

    else
    return $stylesheet_dir_uri . ‘/style.css’; // our default stylesheet

Viewing 15 replies - 1 through 15 (of 22 total)