Organize information in alphabetical order - Html / JavaScript or Wordpress

0

Next,

I have a site in wordpress , I created a page inside that site and on this page I will have a list of companies something like this:

  

Company A - (Company name)

     
  • Company data (This data will be hidden, will appear when the user clicks on the company name).
  •   

Company B

     

Company C

I'm going to feed this list manually so I can have a day I'm going to add company that starts with X the other day company that starts with B and so goes.

Is it possible to do an automatic organization via javascript, where I put one company underneath the other independent of the initial letter of its name and when to go alphabetically?

I do not know if the question was clear, but in summary I want to know how to organize a list automatically in alphabetical order.

Thank you.

Personal, as I am using wordpress I opted to use custom post type as the colleagues suggested in the answers, legal I created post type is working right, but it is still a bit complicated to organize them in alphabetical order, I was reading the codex which is a little too complicated alias PRA ME, and it says that the query function is in the query.php file, but in my theme it does not have this file. I took a look at the functions.php files and also did not find anything of query, what exact file should I "move"?

    
asked by anonymous 27.01.2016 / 13:49

2 answers

2

Since you're using Wordpress, could not you enter these companies as a custom post type? Then just insert a loop on the page to display the companies with the alphabetical order argument.

My response will remain incomplete, but for you to base it on, the code for creating a custom post of company type would look something like this:

add_action( 'widgets_init', 'thinkup_widgets_init' );
register_post_type('empresas', array(
'labels' => array(
            'name' => __( 'empresas' ),
            'singular_name' => __( 'Ver empresas' ),
            'add_new' => __('Novo empresas'),
            'add_new_item' => __('Adicionar novo empresas'),
            'edit_item' => __('Editar empresas'),
            'new_item' => __('Novo empresas'),
            'view_item' => __('Visualizar empresas'),
            'search_items' => __('Pesquisar empresas')
),
'menu_position' => 3,
'public' => true,
'publicly_queryable' => true,
'query_var' => true,
'has_archive' => true,
'hierarchical' => false,
'rewrite' => array('slug' => 'empresas'),
'show_ui' => true,
'capability_type' => 'post',
'supports' => array('title', 'thumbnail', 'revisions' , 'editor', 'excerpt'  )
)
);

A new type of Post will appear on your dashboard, add the companies there. And to pull those companies in a loop, part of the argument code for ordering would look something like this:

$args = array(

  'post_type' => array('empresas'),
  'posts_per_page' => 6,
   'orderby' => 'name',
   );

I hope you have some idea of what to do.

    
27.01.2016 / 14:05
-1

This is a form of ordering for array in javascript.

var items = [
  { name: 'Edward', value: 21 },
  { name: 'Sharpe', value: 37 },
  { name: 'And', value: 45 },
  { name: 'The', value: -12 },
  { name: 'Magnetic' },
  { name: 'Zeros', value: 37 }
];
items.sort(function (a, b) {
  if (a.name > b.name) {
    return 1;
  }
  if (a.name < b.name) {
    return -1;
  }
  // a must be equal to b
  return 0;
});
    
27.01.2016 / 14:10