Results 1 to 2 of 2

Thread: New page types and taxonomies

  1. #1
    Thread Starter
    Expired Customer climbinglizard's Avatar
    Join Date
    Nov 2013
    Location
    Germany
    Posts
    17
    Thanks
    1
    Thanked 0 Times in 0 Posts

    New page types and taxonomies

    I need to offer products another page types.
    I have the whole previously in a separate exercise theme tried thus in the real function.php in my Child of vantage it is not working now.

    I have in the Child of vintage anderst what to do?

    I have the following php code in my function.php Cild

    PHP Code:
    <?php
       add_action
    'init''add_cpt_produkte' );

       function 
    add_cpt_produkte() {

       
    $labels = array(
          
    'name' => _x('Produkte''post type general name'),
          
    'singular_name' => _x('Produkt'
            
    'post type singular name'),
          
    'add_new' => _x('Hinzufügen''Produkt'),
          
    'add_new_item' => __('Neues Produkt hinzufügen'),
          
    'edit_item' => __('Produkt bearbeiten'),
          
    'new_item' => __('Neues Produkt'),
          
    'view_item' => __('Produkt ansehen'),
          
    'search_items' => __('Nach Produkten suchen'),
          
    'not_found' =>  __('Keine Produkte gefunden'),
          
    'not_found_in_trash' => 
          
    __('Keine Produkte im Papierkorb'),
          
    'parent_item_colon' => ''
       
    );

       
    $supports = array( 'title'
                          
    'editor'
                          
    'thumbnail'
                          
    'excerpt');
      
       
    $args = array(
          
    'labels' => $labels,
          
    'public' => true,
          
    'publicly_queryable' => true,
          
    'show_ui' => true
          
    '_builtin' => false,
          
    'show_in_menu' => true
          
    'query_var' => true,
          
    'rewrite' => array("slug" => "produkte"),
          
    'capability_type' => 'post',
          
    'hierarchical' => false,
          
    'has_archive' => true
          
    'hierarchical' => false,
          
    'menu_position' => 20,
          
    'supports' => $supports
       
    ); 
      
       
    register_post_type('Produkt',$args);
      
       }
       
       
    add_action("admin_init""cpt_produkt_meta_boxen");
       
    add_action('save_post''cpt_produkt_daten_speichern');

       function 
    cpt_produkt_meta_boxen(){
          
    add_meta_box("preis-meta""Preis"
            
    "cpt_produkt_feld_preis""produkt""side""high");
          
    add_meta_box("kurzbeschreibung-meta""Kurzbeschreibung"
            
    "cpt_produkt_feld_kurzbeschreibung""produkt""side"
            
    "high");
       }

       function 
    cpt_produkt_feld_preis(){
          global 
    $post;
          
    $custom get_post_custom($post->ID);
          
    $preis $custom["preis"][0];
          echo 
    '<input name="preis" value="' $preis '" /> 
            &euro;'
    ;
       }

       function 
    cpt_produkt_feld_kurzbeschreibung(){
          global 
    $post;
          
    $custom get_post_custom($post->ID);
          
    $kurzbeschreibung $custom["kurzbeschreibung"][0];
          echo 
    '<textarea name="kurzbeschreibung">' $kurzbeschreibung '</textarea>';
       }

       function 
    cpt_produkt_daten_speichern(){
          global 
    $post;
          
    update_post_meta($post->ID"preis"$_POST["preis"]);
          
    update_post_meta($post->ID"kurzbeschreibung"
            
    $_POST["kurzbeschreibung"]);
       }
       
       
    add_action'init''cpt_reg_tax' );

       function 
    cpt_reg_tax() {

       
    register_taxonomy"Leistungen"
           array( 
    "produkt" ), 
           array(  
    "hierarchical"      => true
                   
    "label"             => "Leistungen"
                   
    "singular_label"    => "Leistung"
                   
    "rewrite"           => true));
                                    
       
    register_taxonomy"Preisklasse",
           array( 
    "produkt" ), 
           array( 
    "hierarchical"       => true
                   
    "label"             => "Preisklasse"
                   
    "singular_label"    => "Preisklasse"
                   
    "rewrite"           => true));

       }

       
    add_filter("manage_edit-produkt_columns"
       
    "cpt_produkt_spalten");
       
    add_action("manage_posts_custom_column",  
       
    "cpt_produkt_neue_spalte");

       function 
    cpt_produkt_spalten($columns){
          
    $columns = array(
                     
    "cb" => "<input type=\"checkbox\" />",
                     
    "title" => "Produktname",
                     
    "preis" => "Preis",
                     
    "kurzbeschreibung" => "Kurzbeschreibung",
                     
    "date" => "Hinzugefügt"
          
    );

          return 
    $columns;
       }

       function 
    cpt_produkt_neue_spalte($column){
          global 
    $post;
            
          if (
    "preis" == $column) {
             
    $custom get_post_custom();
             echo 
    $custom["preis"][0];
          }
            
          elseif (
    "kurzbeschreibung" == $column) {
             
    $custom get_post_custom();
             echo 
    $custom["kurzbeschreibung"][0];
          }
       }


    ?>
    Furthermore, an archive-page produkt.php and a single-produkt.php:

    PHP Code:
    <?php /* Template Name: Produktuebersicht */ ?>
    <?php get_header
    (); ?>
    <div id="content">
    <h1 class="archive">Unsere Produkte</h1>
    <ul>

    <?php 
    query_posts
    ('post_type=produkt&post_status=publish');

    if ( 
    have_posts() ) : while ( have_posts() ) : the_post(); 
    ?>

    <li><?php the_date('d.m.Y'); ?> - 
    <a href="<?php the_permalink(); ?>" title="Lesen Sie 
    &quot;<?php the_title(); ?>&quot;"><strong>
    <?php the_title(); ?></strong></a></li>

    <?php endwhile; endif; wp_reset_query(); ?>
        
    </ul>
    </div>
    <?php get_sidebar(); ?>
    <?php get_footer
    (); ?>
    PHP Code:
      <?php get_header(); ?>
       <div id="content">

       <?php if ( have_posts() ) : 
         while ( 
    have_posts() ) : the_post(); ?>

       <?php $custom_fields get_post_custom$post->ID ); ?>

       <h1 class="archive"><?php the_title(); ?> 
         (<?php echo $custom_fields["preis"][0]; ?> &euro;)</h1>

       <?php
       
    if ( function_exists('has_post_thumbnail') && 
         
    has_post_thumbnail() ) {
          
    the_post_thumbnail();
       }
       
    ?>
       <p><strong>Kurzbeschreibung:</strong><br /><em>
         <?php echo $custom_fields["kurzbeschreibung"][0]; 
         
    ?></em></p>
        
       <?php the_content(); ?>
        
       <?php
       $leistungen 
    get_the_term_list$post->ID'Leistungen' );
       
    $preisklasse get_the_term_list$post->ID'Preisklasse' 
         
    );
       
    ?>
       <p>Leistungen: <?php echo $leistungen?></p>
       <p>Preisklasse: <?php echo $preisklasse?></p>

       <?php endwhile; endif; ?>

       </div>
       <?php get_sidebar(); ?>
       <?php get_footer(); ?>
    in the backend I can already but the products invest in the front end is always displayed 404 not found.

    Thank you

  2. #2
    dimitris's Avatar
    Join Date
    Oct 2011
    Location
    Earth
    Posts
    20,617
    Thanks
    222
    Thanked 1,873 Times in 1,770 Posts
    You must be an AppThemes customer and logged in to view this response. Join today!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Classipress without Custom Post Types & Custom Taxonomies
    By wasee in forum ClassiPress General Discussion
    Replies: 3
    Last Post: January 26th, 2013, 03:54 PM
  2. Classipress without Custom Post Types & Custom Taxonomies
    By wasee in forum Report ClassiPress Bugs
    Replies: 1
    Last Post: January 12th, 2013, 02:27 AM
  3. Types and Views on Custom Post Types
    By johnlanglois in forum Vantage General Discussion (Legacy)
    Replies: 1
    Last Post: October 17th, 2012, 09:50 PM
  4. Custom Taxonomies and custom post types in Classipress
    By carlos takemura in forum ClassiPress General Discussion
    Replies: 1
    Last Post: July 8th, 2010, 04:26 PM