κατασκευή ιστοσελίδων θεσσαλονίκη
  • ΑΡΧΙΚΗ
  • TOASTEDWEB
  • ΤΙ ΚΑΝΟΥΜΕ
    • Κατασκευή ιστοσελίδων
    • Κατασκευή eshop
    • Διαφήμιση Google Adwords
    • Διαφήμιση στο facebook
    • Προώθηση ιστοσελίδων
    • Φιλοξενία ιστοσελίδων
    • Ιστοσελίδες για ΑΜΕΑ με το πρότυπο WCAG 2.0
    • ΚΑΝΟΥΜΕ ΚΑΙ ΑΛΛΑ
      • Διαγωνισμοί Facebook
      • Εφαρμογές android
      • Joomla extensions
  • ΠΩΣ ΤΟ ΚΑΝΟΥΜΕ
  • PORTFOLIO
  • ΕΠΙΚΟΙΝΩΝΙΑ
create-taxnomy-screen

Δημιουργία custom post type & taxonomy

Ιανουάριος 6, 2017avasilBlog

Υπάρχει ένα πολύ εύκολο plugin που ονομάζεται PTB  και μπορει να σας κάνει την ζωή εύκολη.

Εάν όμως προτιμάτε ποιο παραδοσιακό τρόπο τότε δείτε τον παρακάτω κώδικα που πρέπει να βάλετε στο functions.php

 

//Δημιουργια του custom post type με όνομα seminars
function seminar_register() {
    $labels = array(
        'name' => _x('seminars', 'post type general name'),
        'singular_name' => _x('seminar', 'post type singular name'),
        'add_new' => _x('Newr', 'portfolio item'),
        'add_new_item' => __('Add new seminar'),
        'edit_item' => __('Edit seminar'),
        'new_item' => __('New seminar'),
        'view_item' => __(View seminar'),
        'search_items' => __('Search for seminars'),
        'not_found' =>  __('Not found'),
        'not_found_in_trash' => __('Not found in trash'),
        'parent_item_colon' => ''
    );
    $args = array(
        'labels' => $labels,
        'public' => true,
        'publicly_queryable' => true,
        'show_ui' => true,
        'query_var' => true,
        'rewrite' => true,
        'capability_type' => 'post',
        'hierarchical' => false,
        'menu_position' => null,
        'supports' => array('title','editor','thumbnail'),
        'taxonomies' => array('category', 'post_tag', 'customtaxonomy')
      );
    register_post_type( 'seminar' , $args );
}
add_action('init', 'seminar_register');
//end creating custom post type\

Αυτο θα σας εμφανίσει στο αριστερο μενου του διαχειριστή ενα νέο υπομενου με όνομα Seminars

 Στον κώδικα θα δείτε στην γραμμή taxonomies τα εξής

‘taxonomies’ => array(‘category’, ‘post_tag’, ‘customtaxonomy’)

εδώ δηλώνω τι έξτρα taxonomies θελω να εχει το custom post type . Βλέπετε μια τιμή customtaxonomy όπου ειναι μια τυαία που έβαλα εγώ. Θα μπορούσε ας πουμέ να λέει ότι θέλουμε πχ εισηγητες. Οτι και να βάλω εκεί θα πρέπει να έχουμε ήδη δηλώσει το taxonomy.
Αυτο γίνεται με 2 τρόπους. Είτε με χρήση Plugin
Simple Taxonomy WordPress plugin
create-taxnomy-screen

Ο δεύτερος τρόπος είναι με κώδικα πάλι στην σελίδα του functions.php
ευτηχώς εδώ https://generatewp.com/taxonomy/ υπάρχει ενα εργαλείο που μας κάνει την ζωη έυκολη!

πχ δημιουργια ενός taxonomy με όνομα Κατηγορία Σεμιναρίων που αφορά τα custom post types με όνομα Seminars

// Register Custom Taxonomy
function categoryofseminars() {
    $labels = array(
        'name'                       => _x( 'Κατηγορίες', 'Taxonomy General Name', 'text_domain' ),
        'singular_name'              => _x( 'Κατηγορία', 'Taxonomy Singular Name', 'text_domain' ),
        'menu_name'                  => __( 'Κατηγορία σεμιναρίου', 'text_domain' ),
        'all_items'                  => __( 'All Items', 'text_domain' ),
        'parent_item'                => __( 'Parent Item', 'text_domain' ),
        'parent_item_colon'          => __( 'Parent Item:', 'text_domain' ),
        'new_item_name'              => __( 'New Item Name', 'text_domain' ),
        'add_new_item'               => __( 'Add New Item', 'text_domain' ),
        'edit_item'                  => __( 'Edit Item', 'text_domain' ),
        'update_item'                => __( 'Update Item', 'text_domain' ),
        'view_item'                  => __( 'View Item', 'text_domain' ),
        'separate_items_with_commas' => __( 'Separate items with commas', 'text_domain' ),
        'add_or_remove_items'        => __( 'Add or remove items', 'text_domain' ),
        'choose_from_most_used'      => __( 'Choose from the most used', 'text_domain' ),
        'popular_items'              => __( 'Popular Items', 'text_domain' ),
        'search_items'               => __( 'Search Items', 'text_domain' ),
        'not_found'                  => __( 'Not Found', 'text_domain' ),
        'no_terms'                   => __( 'No items', 'text_domain' ),
        'items_list'                 => __( 'Items list', 'text_domain' ),
        'items_list_navigation'      => __( 'Items list navigation', 'text_domain' ),
    );
    $args = array(
        'labels'                     => $labels,
        'hierarchical'               => true,
        'public'                     => true,
        'show_ui'                    => true,
        'show_admin_column'          => true,
        'show_in_nav_menus'          => true,
        'show_tagcloud'              => true,
    );
    register_taxonomy( 'categoryof', array( 'seminars' ), $args );
}
add_action( 'init', 'categoryofseminars', 0 );

Τελευταία άρθρα

  • A/B testing
  • Δημιουργία custom post type & taxonomy
  • Acf , custom fields , εμφάνιση σε page , post , widget του Wordrpress
  • Woocommerce | list all attributes by name and items
  • WooCommerce Custom Product Data Fields – check box

Αρχείο

  • Φεβρουάριος 2017
  • Ιανουάριος 2017
  • Σεπτέμβριος 2016
  • Ιούλιος 2016
  • Ιούνιος 2016
  • Μάιος 2016
  • Απρίλιος 2016
  • Ιανουάριος 2016
  • Νοεμβρίου 2015
  • Σεπτέμβριος 2015
  • Ιούλιος 2015
  • Ιούνιος 2015
  • Απρίλιος 2015
  • Μάρτιος 2015
  • Δεκέμβριος 2014
  • Νοεμβρίου 2014
  • Οκτώβριος 2014
  • Σεπτέμβριος 2014
  • Ιανουάριος 2014

ΒΡΑΒΕΥΣΕΙΣ

ΠΟΛΙΤΙΚΗ ΑΠΟΡΡΗΤΟΥ
ΥΠΟΣΤΗΡΙΞΗ
BLOG
SITEMAP

toastedweb

HELLO@TOASTEDWEB.GR

+30 231 220 30 35

ΝΙΚΗΣ 14
55535,ΠΥΛΑΙΑ ΘΕΣΣΑΛΟΝΙΚΗ


Facebook
Twitter
Google+

Toastedweb’s Lounge

  • A/B testing
  • Δημιουργία custom post type & taxonomy
  • Acf , custom fields , εμφάνιση σε page , post , widget του Wordrpress
  • Woocommerce | list all attributes by name and items
© 2017 Toastedweb.gr - κατασκευή ιστοσελίδων Θεσσαλονίκη