0
Welcome Guest! Login
0 items Join Now

SOLVED How order the single.php meta catgory by id

  • SOLVED How order the single.php meta catgory by id

    Posted 8 years 10 months ago
    • Hi, i try to order the meta information of the single.php for have the categories order by id.. but i don’t find were make the change i see in the meta.html.twig and i find de loop {% for category in post.categories %} but i don’t now how change it for displays the categories in ID order… I try a conditional like..

      {% categories = get_categories( array('orderby' => 'id', 'order' => 'ASC') ); %}
      {% for category in post.categories %} …

      but doesn’t work… Can someone help me ?
    • Damir's Avatar
    • Damir
    • Preeminent Rocketeer
    • Posts: 22450
    • Thanks: 2679
    • Web Developer

    Re: SOLVED How order the single.php meta catgory by id

    Posted 8 years 10 months ago
  • Re: SOLVED How order the single.php meta catgory by id

    Posted 8 years 10 months ago
    • Hi, tks for your help... i try but it don’t work i have the next code in the file single.php
      defined('ABSPATH') or die;
      
      $gantry = Gantry\Framework\Gantry::instance();
      $theme  = $gantry['theme'];
      
      // We need to render contents of <head> before plugin content gets added.
      $context              = Timber::get_context();
      $context['page_head'] = $gantry->isCompatible('5.1.5') ? $theme->render('partials/page_head.html.twig', $context) : null;
      
      
      $post            = Timber::query_post();
      $context['post'] = $post;
      $context['wp_title'] .= ' - ' . $post->title();
      $context['categories'] = Timber::get_terms('category', array('orderby' => 'id', 'order' => 'ASC'));
      
      if (in_category(array( 22, 73, 71, 155 ))) {	
          Timber::render(['single2.html.twig'], $context);	
      } 
      else if (in_category (array( 10, 11, 12, 13, 14, 59, 55, 57, 61, 77, 79, 81, 83, 85, 133, 183, 185, 187, 189, 191 ))) {
      	Timber::render(['singleAxes.html.twig'], $context);
      }
      
      else if (in_category (array( 15, 129, 221, 223, 217 ))) {
      	
      	Timber::render(['singlePublications.html.twig'], $context);
      }
      
      else {	
      	Timber::render(['single-' . $post->ID . '.html.twig', 'single-' . $post->post_type . '.html.twig', 'single.html.twig'], $context);
      }
      

      and i have also one file metaPublications.html.twig ... so i don’t now if its necessary to insert in this one and how make twig compatible ;(


      {% set twigTemplate = 'meta.html.twig' %}
      
      
      <div class="entry-meta">
      
          {% block meta %}
      	
      	
      		{# Begin Meta - Categories #}
              {% if gantry.config.get('content.' ~ scope ~ '.meta-categories.enabled', '1') and post.categories is not empty %}
                  <div class="meta-categories">
                      <i class="fa fa-bookmark"></i> 
      				
      				
      
                      {% if gantry.config.get('content.' ~ scope ~ '.meta-categories.prefix', 'Categorie :') is not empty %}
            				
      					    <span class="meta-prefix">CréaTIC - </span>
      					
      			    {% endif %}
      
                      <span class="categories">
      				    
      									
                          {% for category in post.categories %}
      					     
                              {%- if gantry.config.get('content.' ~ scope ~ '.meta-categories.link', '1') -%}
                                  <a href="{{ category.link }}" title="{{ category.name }}" class="meta-category-link"><span class="single-cat">{{ category.name }} </span></a>
      												
                              {%- else -%}
                                  <span class="single-cat">{{ category.name }} </span>
                              {%- endif -%}
                              {% if not loop.last %}{{ ' - '|trim }}{% endif %}
                          {% endfor %}
                      </span>
    • Last Edit: 8 years 10 months ago by Ghislaine AZEMARD.
    • Damir's Avatar
    • Damir
    • Preeminent Rocketeer
    • Posts: 22450
    • Thanks: 2679
    • Web Developer

    Re: SOLVED How order the single.php meta catgory by id

    Posted 8 years 10 months ago
  • Re: SOLVED How order the single.php meta catgory by id

    Posted 8 years 10 months ago
    • Tks again, now its show me all the categories in my site and not only the categories of Article... how can i solve that ?
    • Damir's Avatar
    • Damir
    • Preeminent Rocketeer
    • Posts: 22450
    • Thanks: 2679
    • Web Developer

    Re: SOLVED How order the single.php meta catgory by id

    Posted 8 years 10 months ago
  • Re: SOLVED How order the single.php meta catgory by id

    Posted 8 years 10 months ago
    • Kool... thanks

Time to create page: 0.065 seconds