← WordPress

Custom Post Types

Lida 2333 vezes

Offline

João Godinho 
Membro
Mensagens 1755 Gostos 2
Troféus totais: 27
Trófeus: (Ver todos)
Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Level 5 Level 4 Level 3 Level 2 Level 1

Código: (php) [Seleccione]
add_action( 'init', 'create_post_type_portefolio' );

function create_post_type_portefolio() {

    $labels = array(
    'name' => _x('Portefólio', 'post type general name'),
    'singular_name' => _x('Portefólio', 'post type singular name'),
'capability_type' => 'portefolio',
    'add_new' => _x('Adicionar Novo', 'portefolio'),
    'add_new_item' => __('Adicionar novo Trabalho'),
    'edit_item' => __('Editar Trabalho'),
    'new_item' => __('Novo Trabalho'),
    'all_items' => __('Todos os Trabalhos'),
    'view_item' => __('Ver Trabalho'),
    'search_items' => __('Procurar Trabalhos'),
    'not_found' =>  __('Nenhum trabalho encontrado.'),
    'not_found_in_trash' => __('Sem trabalhos no lixo'),
    'parent_item_colon' => '',
    'menu_name' => 'Portefólio'
    );


    register_post_type( 'portefolio', array(
    'labels' => $labels,
    'public' => true,
    'publicly_queryable' => true,
    'show_ui' => true,
    'show_in_menu' => true,
    'has_archive' => 'portefolio',
    'rewrite' => array(
'slug' => 'portefolio',
'with_front' => false,
    ),
    'capability_type' => 'post',
    'has_archive' => true,
    'hierarchical' => false,
    'menu_position' => null,
    'supports' => array('title', 'editor', 'thumbnail')
    )
    );
    flush_rewrite_rules();

    register_taxonomy( 'film_category', array( 'portefolio' ), array(
        'hierarchical' => true,
        'label' => __( 'Categoria de Portefólio' ),
        'labels' => array( // Labels customizadas
    'name' => _x( 'Categorias', 'taxonomy general name' ),
    'singular_name' => _x( 'Categoria', 'taxonomy singular name' ),
    'search_items' =>  __( 'Procurar Categorias' ),
    'all_items' => __( 'Todas as Categorias' ),
    'parent_item' => __( 'Parent Category' ),
    'parent_item_colon' => __( 'Parent Category:' ),
    'edit_item' => __( 'Editar Categoria' ),
    'update_item' => __( 'Actualizar Categoria' ),
    'add_new_item' => __( 'Adicionar nova Categoria' ),
    'new_item_name' => __( 'Novo Nome de Categorua' ),
    'menu_name' => __( 'Categoria' ),
),
        'show_ui' => true,
        'show_in_tag_cloud' => true,
        'query_var' => true,
        'rewrite' => array( 'slug' => 'portefolio' ),
        )
    );
}
Boas Pessoal,
Isto é o que tenho para criar o Custom Post Type para o Portefólio. Tudo tá a funcionar bem.

Apenas a disposição dos posts de cada categorias definido pelo archive-portefolio.php não está a funcionar, supostamente deveria estar em http://localhost/pormenor/portefolio/web-design e quando se acede dá Erro 404.

Alguém pode dar um vista de olhos e ver se tenho algum erro?
Offline

João Godinho 
Membro
Mensagens 1755 Gostos 2
Troféus totais: 27
Trófeus: (Ver todos)
Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Level 5 Level 4 Level 3 Level 2 Level 1

Alguém?
Offline

Jóni Oliveira 
Administrador
Mensagens 3428 Gostos 395
Feedback +28

Troféus totais: 35
Trófeus: (Ver todos)
Tenth year Anniversary Nineth year Anniversary Mobile User Apple User Level 6 Windows User Super Combination Combination Topic Starter 10 Poll Votes

Quanto ao custom post type não te consigo ajudar... mas o:
Citar
Apenas a disposição dos posts de cada categorias definido pelo archive-portefolio.php não está a funcionar, supostamente deveria estar em http://localhost/pormenor/portefolio/web-design e quando se acede dá Erro 404.

 :-k Consegues abrir alguma pagina desse wp com friendly url em localhost?
Offline

João Godinho 
Membro
Mensagens 1755 Gostos 2
Troféus totais: 27
Trófeus: (Ver todos)
Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Level 5 Level 4 Level 3 Level 2 Level 1

Sim, tudo. Até esta url: http://localhost/pormenor/portefolio/trabalho que é feita na mesma função.
Offline

João Godinho 
Membro
Mensagens 1755 Gostos 2
Troféus totais: 27
Trófeus: (Ver todos)
Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Level 5 Level 4 Level 3 Level 2 Level 1

Ninguém me sabe ajudar?
Offline

rtbfreitas 
Equipa
Mensagens 1497 Gostos 9
Feedback +24

Troféus totais: 30
Trófeus: (Ver todos)
Windows User Apple User Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Poll Starter Level 5 Level 4

Código: [Seleccione]
register_taxonomy( 'film_category'
Não será ai o erro? O que é que o "film_category está ai a fazer?
Offline

João Godinho 
Membro
Mensagens 1755 Gostos 2
Troféus totais: 27
Trófeus: (Ver todos)
Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Level 5 Level 4 Level 3 Level 2 Level 1

Já corrigi, no entanto agora dá-me este erro quando entro no menu de categorias: Taxonomia inválida
Offline

João Godinho 
Membro
Mensagens 1755 Gostos 2
Troféus totais: 27
Trófeus: (Ver todos)
Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Level 5 Level 4 Level 3 Level 2 Level 1

Consegui resolver isso, usando isto:
Código: (php) [Seleccione]
// Portfólio
register_post_type('Portefólio', array( 'label' => 'Portefólio','description' => '','public' => true,'show_ui' => true,'show_in_menu' => true,'capability_type' => 'post','hierarchical' => true,'rewrite' => array('slug' => 'portefolio'),'query_var' => true,'has_archive' => true,'supports' => array('title','editor','custom-fields','thumbnail',),'taxonomies' => array('category',),'labels' => array (
  'name' => 'Portefólio',
  'singular_name' => 'Projectos',
  'menu_name' => 'Portefólio',
  'add_new' => 'Adicionar novo',
  'add_new_item' => 'Adicionar novo Projecto',
  'edit' => 'Editar',
  'edit_item' => 'Editar Projecto',
  'new_item' => 'Novo Projecto',
  'view' => 'Ver Projecto',
  'view_item' => 'Ver Projecto',
  'search_items' => 'Procurar Projectos',
  'not_found' => 'Nenhum Projecto Encontrado',
  'not_found_in_trash' => 'Nenhum Projecto encontrado no Lixo',
  'parent' => 'Parent Projectos',
),) );
register_taxonomy('tipodeprojectos',array (
  0 => 'porteflio',
),array( 'hierarchical' => true, 'label' => 'Tipo de Projecto','show_ui' => true,'query_var' => true,'rewrite' => array('slug' => 'projectos'),'singular_label' => 'Tipo de Projecto') );
// Fim Portefólio
Fiz tudo de novo.

Supostamente a disposição dos posts por categorias (http://localhost/pormenor/projectos/web-design/) devia seguir o template archive-portefolio.php
E a disposição sozinho devia seguir o single-portefolio.php o que não acontece  :-k

Isso não acontece e os templates que seguem é o de archive.php e single.php

Alguém pode ver se há alguma coisa no functions.php que faça com que isso aconteça?

 :obrigado: