Viewing 15 posts - 1 through 15 (of 15 total)
  • Author
    Posts
  • #790107

    Hi,
    I need to show categories in the class for the article in the post grid list (http://kriesi.at/themes/enfold-2017/blog/blog-default/)
    Can you help me?

    #790299

    Hey marcomila,

    Can you give us temporary admin access to your website in the private content box below, so that we can have a closer look.

    Best regards,
    Victoria

    #790311

    Hi,
    here the website

    The site is under construction for the moment.
    Cheers

    #790414

    Hi marcomila,

    Is this the page where you are trying to add categories?
    You can give us temporary admin access to your website in the private content box below, we will not publish your site, no worries :)

    Best regards,
    Victoria

    #790416

    Hi,
    yes

    #790529

    Hi marcomila,

    But you have categories there. I am not sure I understand what you need to do here. Or did you get it solved already?

    Best regards,
    Victoria

    #790547

    As you can see there are categories visible for every single post, but i need to have the category name in the article class, in the html.
    I mean somethig like this:
    <article class=”Category-name category-name-2 …”>

    How can i add this??

    #790623

    Hi,

    That would require to modify the shortcodes template.
    You can use a child theme and the following code

    and then you can go ahead and try do those changes. For exmaple, after modify you can use get_category_id to load the id or name as per your needs

    Best regards,
    Basilis

    #790649

    I’m using a child theme.
    I’m working on postslider.php, where I found this line:
    $output .= “<article class=’slide-entry flex_column {$style} {$post_class} {$grid} {$extraClass} {$thumb_class}’ $markup>”;

    I think I can add a code in this line to show the category, isn’t it?
    Which code?

    #791333

    Hey, anyone knows a solution?

    #791714

    Hi marcomila,

    I see you have the classes added already. Great job! Anything else left to do?

    Best regards,
    Victoria

    #791716

    Hi,
    the classes you read are the results of a custom fields.
    I’m not able to add the category in the class.

    Anyway, I’ve got another question: How can I sort the post category like this:
    parent, child category, …
    Now are sorted for their ID in the breadcrumb, and alphabetical in the post grid.
    Any idea?

    #792239

    Hi marcomila,

    To sort post how you want you need to modify the query that gets posts from the database.
    To add categories as a class you need to take this code in loop-index.php:

    
    foreach((get_the_category($the_id)) as $category) {
    						if ($category->category_parent == 0) {
    							$parentscategory .= ' <a href="' . get_category_link($category->cat_ID) . '" title="' . $category->name . '">' . $category->name . '</a> ';
    							//$parents=	get_category_parents( $category->cat_ID, true, ' » ' );
    						}else{
    							$parents.=' <a href="' . get_category_link($category->cat_ID) . '" title="' . $category->name . '">' . $category->name . '</a> ';
    						}
    						
    				}
                	

    And use it to make a string with classes and add them to “

    #792242

    Hi Victoria,
    thanks for your reply.
    Can you explain what you mean with “And use it to make a string with classes and add them to “?
    Can you write an example please?

    #792883

    Hi marcomila,

    You have this loop, going through all categories of the post, you want their names as class, right? So use their names in a space separated string and assign it as a class.

    Best regards,
    Victoria

Viewing 15 posts - 1 through 15 (of 15 total)
  • You must be logged in to reply to this topic.