• Resolved densdj

    (@densdj)


    Hi, i red closed topic “How to show location in place of date. (Grid layout)” I want to show category in place of date. Tried this code, but it don’t work:
    .advert-item-col-2 span.advert-date,
    .advert-item-col-3 span.advert-date,
    .advert-item-col-4 span.advert-date {
    display: none !important;
    }
    .advert-item-col-2 .advert-category.adverts-icon-tags,
    .advert-item-col-3 .advert-category.adverts-icon-tags,
    .advert-item-col-4 .advert-category.adverts-icon-tags, {
    display: inline-block !important;
    }

    Please help, where is my mistake?

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author Greg Winiarski

    (@gwin)

    Hi,
    unfortunately, the category is not shown on the [adverts_list] at all so it is not possible to show using just a CSS code.

    To show the category in place of the date you would need to open file wpadverts/templates/list-item.php and replace line

    
    <?php echo date_i18n( get_option( 'date_format' ), get_post_time( 'U', false, get_the_ID() ) ) ?>
    

    with

    
    <?php $advert_category = get_the_terms( get_the_ID(), 'advert_category' ) ?>
    <?php if( isset( $advert_category[0] ) ): ?>
    <?php echo join( " / ", advert_category_path( $advert_category[0] ) ) ?> 
    <?php endif; ?>
    

    Please note the changes you will do in list-item.php will be overwritten on WPAdverts update in order to avoid that please consider creating a child template file for list-item.php as explained here https://wpadverts.com/documentation/child-themes-and-templates/

    Thread Starter densdj

    (@densdj)

    Thanks, works perfect.

    Thread Starter densdj

    (@densdj)

    One more question, how to show only primary category, in place of date. For example: “moto cars\opel”, here primary category only opel (is set in classified category column), i want to show only opel in place of date.

    Thread Starter densdj

    (@densdj)

    2)And about topic “Hide a category”, is it possible to make Restricted Categories extension, to work with classifieds categories too, it works only with posts categories (again sorry for my English)

    Plugin Author Greg Winiarski

    (@gwin)

    1. to show only the category name and not full path replace line

    
    <?php echo join( " / ", advert_category_path( $advert_category[0] ) ) ?> 
    

    with

    
    <?php echo esc_html( $advert_category[0]->name ) ?>
    

    2. i am not sure what do you mean exactly? The Restricted Categories extension (https://wpadverts.com/extensions/restricted-categories/) actually works with the Adverts and not with Posts?

    Can you maybe explain it in some more details?

    Thread Starter densdj

    (@densdj)

    I mean this https://imageup.ru/img162/3472410/112.jpg Only posts categories available, classifieds have other categories, they are not in Restricted Categories extension.

    Thread Starter densdj

    (@densdj)

    Sorry, it was other extension.

    Plugin Author Greg Winiarski

    (@gwin)

    Ok no problem, i understand you have the issue resolved? If so then i am marking the thread as resolved.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘How to show category in place of date. (Grid layout)’ is closed to new replies.