Forum Pplware

Versão Completa: criar Custom Post (duvidas básicas) wordpress
Está de momento a ver uma versão reduzida do nosso conteúdo. Ver versão completa com o formato adequado.
Tentei criar uma Custom Post type, por isso estou a seguir este totorial - http://www.escolawp.com/2011/11/guia-def...s-parte-1/

O problema que agora estou a encontrar são em perguntas básicas que um iniciado poderá ter, pelo menos eu tenho:

O theme que tenho em mãos é o de baixo (dito no código). O que estou a tentar fazer é criar um custom post (uma entrada) depois das páginas. Ou seja. Tenho de saber em que lugar do functions.php do theme coloco o código para aparecer debaixo das páginas. Se também existir um código especifico, não sei qual é. Depois tenho de saber como coloco o código criado por mim para criar um custom post (em que lugar especifico do functions coloco). Imaginamos que quero criar um custum post com o nome filme, não sei onde coloco esse código, em que parte do functions.php (penso que seja lá pelo menos).

Outra situação é a forma como coloco o código. Terei de deixar espaços na pagina functions.php, ou seja, espaçamento? Tem de existir uma distância entre o código que criei com o que já está nessa página? Como fazer? Em baixo deixo como exemplo o functions.php como exemplo, limpo de qualquer custom criado por mim, para poderem explicar como devo fazer.

Código PHP:
<?php

$themename 
"Breath";

$adminmenuname "Breath";

$shortname "am";

define('SHORTNAME','am');

locate_template(array('backend/setup.php'), truetrue);    

locate_template(array('inc/tweaks.php'), truetrue);    

locate_template(array('inc/sidebar-generator.php'), truetrue);    

locate_template(array('inc/posts_type.php'), truetrue);    

locate_template(array('inc/sliders_type.php'), truetrue);    

locate_template(array('inc/portfolios_type.php'), truetrue);
    
locate_template(array('inc/portfolios_tax.php'), truetrue);    

locate_template(array('inc/breadcrumbs.php'), truetrue);    

locate_template(array('inc/widgets.php'), truetrue);
    
locate_template(array('inc/twitter.php'), truetrue);

locate_template(array('inc/shortcodes.php'), truetrue);    


//
load_theme_textdomain'breath'get_template_directory() );
//
if ( function_exists('wp_nav_menu') ) {
    
add_theme_support'menus' );
    function 
register_th_menus() {
        
register_nav_menus(
            array(
                
'header-menu' => __'Header Menu''breath' ),
                
'footer-menu' => __'Footer Menu''breath' )
                )
        );
    }
    
add_action'init''register_th_menus' );
}


//

add_theme_support('post-thumbnails');

//

add_theme_support'automatic-feed-links' );

//


add_editor_style();

//

add_filter('widget_text''do_shortcode');

//

if ( ! isset( $content_width ) ) $content_width 920;

//


    
register_sidebar(array(

        
'id' => 'default-sidebar',
        
        
'description' => __'The default sidebar!''breath'),
        
        
'name' => 'Default sidebar',

        
'before_widget' => '<div id="%1$s" class="widget %2$s">',

        
'after_widget' => '</div>',

        
'before_title' => '<h3 class="widgettitle">',

        
'after_title' => '</h3>',

    ));


register_sidebar(array(

        
'id' => 'footer-1',

        
'name' => 'Footer Column 1',

        
'before_widget' => '<div id="%1$s" class="widget %2$s">',

        
'after_widget' => '</div>',

        
'before_title' => '<h4  class="widgettitle">',

        
'after_title' => '</h4>',

    ));

register_sidebar(array(

        
'id' => 'footer-2',

        
'name' => 'Footer Column 2',

        
'before_widget' => '<div id="%1$s" class="widget %2$s">',

        
'after_widget' => '</div>',

        
'before_title' => '<h4  class="widgettitle">',

        
'after_title' => '</h4>',

    ));
    
register_sidebar(array(

        
'id' => 'footer-3',

        
'name' => 'Footer Column 3',

        
'before_widget' => '<div id="%1$s" class="widget %2$s">',

        
'after_widget' => '</div>',

        
'before_title' => '<h4  class="widgettitle">',

        
'after_title' => '</h4>',

    ));
    
register_sidebar(array(

        
'id' => 'footer-4',

        
'name' => 'Footer Column 4',

        
'before_widget' => '<div id="%1$s" class="widget %2$s">',

        
'after_widget' => '</div>',

        
'before_title' => '<h4  class="widgettitle">',

        
'after_title' => '</h4>',

    ));

register_sidebar(array(

        
'id' => 'footer-additional-1',

        
'name' => 'Footer Additional Line Column 1',

        
'before_widget' => '<div id="%1$s" class="widget %2$s">',

        
'after_widget' => '</div>',

        
'before_title' => '<h4  class="widgettitle">',

        
'after_title' => '</h4>',

    ));
    
register_sidebar(array(

        
'id' => 'footer-additional-2',

        
'name' => 'Footer Additional Line Column 2',

        
'before_widget' => '<div id="%1$s" class="widget %2$s">',

        
'after_widget' => '</div>',

        
'before_title' => '<h4  class="widgettitle">',

        
'after_title' => '</h4>',

    ));
    
register_sidebar(array(

        
'id' => 'footer-additional-3',

        
'name' => 'Footer Additional Line Column 3',

        
'before_widget' => '<div id="%1$s" class="widget %2$s">',

        
'after_widget' => '</div>',

        
'before_title' => '<h4  class="widgettitle">',

        
'after_title' => '</h4>',

    ));
    
register_sidebar(array(

        
'id' => 'footer-additional-4',

        
'name' => 'Footer Additional Line Column 4',

        
'before_widget' => '<div id="%1$s" class="widget %2$s">',

        
'after_widget' => '</div>',

        
'before_title' => '<h4  class="widgettitle">',

        
'after_title' => '</h4>',

    ));



//print scripts
add_action('init''am_register_scripts');
add_action('wp_footer''am_print_scripts');
 
function 
am_register_scripts() {

    
wp_register_script('modernizer'get_template_directory_uri() .'/js/modernizr.min.js', array('jquery'), null); 
    
wp_register_script('validate'get_template_directory_uri() .'/js/validate/jquery.validate.min.js', array('jquery'), nulltrue); 
    
    
wp_register_script('jui'get_template_directory_uri() .'/js/jquery-ui.min.js', array('jquery'), nulltrue); 
    
        
    
    
wp_register_script('jcycle'get_template_directory_uri() .'/js/jcycle/jquery.cycle.all.js', array('jquery'), null,true);     
    
wp_register_script('superfish'get_template_directory_uri() .'/js/superfish/superfish.js', array('jquery'), null,true); 
    
wp_register_script('prettyphoto'get_template_directory_uri() .'/js/prettyphoto/js/jquery.prettyPhoto.php', array('jquery'), null,true);     
    
wp_register_script('isotope'get_template_directory_uri() .'/js/isotope/jquery.isotope.min.js', array('jquery'), null,true); 
    
wp_register_script('th_scripts'get_template_directory_uri() .'/js/script.php', array('jquery'), null,true);
    
wp_register_script('preview'get_template_directory_uri() .'/js/preview.php', array('jquery'), null,true);
    
wp_register_script('th-colorpicker'get_template_directory_uri() .'/backend/js/mColorPicker/javascripts/mColorPicker.php', array('jquery'), nulltrue);
    
    
    
    if(!
is_admin() &&  !in_array$GLOBALS['pagenow'], array( 'wp-login.php''wp-register.php' ) )){
    
wp_enqueue_script('modernizer');    
    
        
    
wp_enqueue_script('superfish');    

    
wp_enqueue_script('prettyphoto');    
    
    if( 
get_option(SHORTNAME."_preview") != '') {
        
    
wp_enqueue_script('preview');
    
wp_enqueue_script('th-colorpicker');
        
    }
    
    
    }
    
}


 
function 
am_print_scripts() {
    global 
$am_carousel$am_isotope$am_validate$am_jcycle$am_tabs;
 
    
    if ( 
$am_jcycle ) { wp_print_scripts('jcycle');  }
    if ( 
$am_isotope ) { wp_print_scripts('isotope');  }
    if ( 
$am_validate ) { wp_print_scripts('validate');  }
    if ( 
$am_tabs ) { wp_print_scripts('jui');  }

    
wp_print_scripts('th_scripts'); 
}




function 
am_add_styles() { 
    global 
$gfont;
    if(!
is_admin()){
    
wp_enqueue_style'main',  get_template_directory_uri() .'/css/main.css','',null'all');
    
wp_enqueue_style'skin',   get_template_directory_uri() .'/css/styles.php','',null'all');
    
wp_enqueue_style'prettyphoto',   get_template_directory_uri() .'/js/prettyphoto/css/prettyPhoto.css','',null'screen');
    }
}

add_action('wp_print_styles''am_add_styles');


//
function imgsrc_original() {
    global 
$post;            
            
    
$post_thumbnail_id get_post_thumbnail_id$post->ID );
           
    
$image_attributes wp_get_attachment_image_src($post_thumbnail_id'full');    
          
    
$imgsrc $image_attributes[0];
    
    echo 
$imgsrc;
                    
    }

//
  
define('ICL_AFFILIATE_ID'7410);
  
define('ICL_AFFILIATE_KEY''52286484063b643175cdfd8e743f1448');
include 
"wpml-integration.php";
  
wpml_register_string('breath''copyright'stripslashes(get_option(SHORTNAME."_copyright")));
  
wpml_register_string('breath''maptitle'stripslashes(get_option(SHORTNAME."_maptitle")));
  
wpml_register_string('breath''formtitle'stripslashes(get_option(SHORTNAME."_formtitle")));
  
wpml_register_string('breath''contact_form_add1'get_option(SHORTNAME."_formadd1"));
  
wpml_register_string('breath''contact_form_add2'get_option(SHORTNAME."_formadd2"));
  
wpml_register_string('breath''contact_form_add3'get_option(SHORTNAME."_formadd3"));
  
wpml_register_string('breath''contact_form_add4'get_option(SHORTNAME."_formadd4"));
  
wpml_register_string('breath''contact_form_add5'get_option(SHORTNAME."_formadd5"));  
  
wpml_register_string('breath''teaser_readmore_1'get_option(SHORTNAME."_teaser_readmore_1"));
  
wpml_register_string('breath''teaser_readmore_2'get_option(SHORTNAME."_teaser_readmore_1"));
  
wpml_register_string('breath''teaser_readmore_3'get_option(SHORTNAME."_teaser_readmore_1"));
  
wpml_register_string('breath''teaser_readmore_4'get_option(SHORTNAME."_teaser_readmore_1"));  
  
function 
language_selector_flags(){
    if(
function_exists('icl_get_languages')) {
    
$languages icl_get_languages('skip_missing=0');
    if(!empty(
$languages)){ ?>
        <ul class="languages">
        <?php
        
foreach($languages as $l){
            if(
$l['active']) echo '<li>';
            if(!
$l['active']) echo '<li><a href="'.$l['url'].'">';
            echo 
'<img src="'.$l['country_flag_url'].'"  alt="'.$l['language_code'].'"  title="'.$l['native_name'].'" />';
            if(!
$l['active']) echo '</a></li>';
            if(
$l['active']) echo '</li>';
        }
        
?> </ul> <?php
    
}
    }
}

function 
wpml_page_id($id){
  if(
function_exists('icl_object_id')) {
    return 
icl_object_id($id,'page',true);
  } else {
    return 
$id;
  }
}

function 
wpml_post_id($id){
  if(
function_exists('icl_object_id')) {
    return 
icl_object_id($id,'post',true);
  } else {
    return 
$id;
  }
}

function 
wpml_cat_id($id){
  if(
function_exists('icl_object_id')) {
    return 
icl_object_id($id,'category',true);
  } else {
    return 
$id;
  }
}

//

function list_comments($comment$args$depth) {

$GLOBALS['comment'] = $comment?>

<li <?php comment_class(); ?> id="li-comment-<?php comment_ID() ?>">

<div id="comment-<?php comment_ID(); ?>" class="comment-body">

<div class="avatars"><?php echo get_avatar($comment,$size='75'); ?></div>

<div class="comment-text">
<div class="comment-meta">

<?php comment_reply_link(array_merge$args, array('depth' => $depth'max_depth' => $args['max_depth']))) ?>

<?php printf('<cite class="fn">%s</cite>'get_comment_author_link()) ?>

<span><?php printf(__('Posted on %1$s at %2$s''breath'), get_comment_date(), get_comment_time()) ?></span> <span>|</span> <a href="<?php echo htmlspecialcharsget_comment_link$comment->comment_ID ) ) ?>" class="comment-date"><?php _e('Permalink''breath'?></a>

</div>

<?php comment_text() ?>

<?php if ($comment->comment_approved == '0') : ?>

<em><?php _e('Your comment is awaiting moderation.''breath'?></em>

<?php endif; ?>
</div>
</div>
<?php 


//
function skin_body_class($classes) {
    if( 
get_option(SHORTNAME."_colorskin") != '') { $stylecolor get_option(SHORTNAME."_colorskin"); } else {$stylecolor "blue"; }
    
$classes[] = $stylecolor;
    return 
$classes;
}

add_filter('body_class''skin_body_class');


// Menu walker

class Sub_Menu_Walker extends Walker_Nav_Menu{

        
    function 
display_element$element, &$children_elements$max_depth$depth=0$args, &$output ) {

        if ( !
$element )
            return;

        
$id_field $this->db_fields['id'];

        
//display this element
        
if ( is_array$args[0] ) )
            
$args[0]['has_children'] = ! empty( $children_elements[$element->$id_field] );
        
        
//Adds the 'parent' class to the current item if it has children        
        
if( ! empty( $children_elements[$element->$id_field] ) )
            
array_push($element->classes,'dropdown');
        
        
$cb_args array_merge( array(&$output$element$depth), $args);
        
        
call_user_func_array(array(&$this'start_el'), $cb_args);

        
$id $element->$id_field;

        
// descend only when the depth is right and there are childrens for this element
        
if ( ($max_depth == || $max_depth $depth+) && isset( $children_elements[$id]) ) {

            foreach( 
$children_elements$id ] as $child ){

                if ( !isset(
$newlevel) ) {
                    
$newlevel true;
                    
//start the child delimiter
                    
$cb_args array_merge( array(&$output$depth), $args);
                    
call_user_func_array(array(&$this'start_lvl'), $cb_args);
                }
                
$this->display_element$child$children_elements$max_depth$depth 1$args$output );
            }
            unset( 
$children_elements$id ] );
        }

        if ( isset(
$newlevel) && $newlevel ){
            
//end the child delimiter
            
$cb_args array_merge( array(&$output$depth), $args);
            
call_user_func_array(array(&$this'end_lvl'), $cb_args);
        }

        
//end this element
        
$cb_args array_merge( array(&$output$element$depth), $args);
        
call_user_func_array(array(&$this'end_el'), $cb_args);
    }
}

//thumbnails

add_image_size('related'7575true);
add_image_size('recent_posts'7045true);
add_image_size('portfolio_widget'110110true);
add_image_size('portfolio_small_sidebar'177158true);
add_image_size('portfolio_small'204158true);
add_image_size('portfolio_medium'284158true);
add_image_size('portfolio_big_sidebar'324248true);
add_image_size('carousel_image'524295true);
add_image_size('portfolio_item_sidebar'604390true);
add_image_size('post_thumbnail'604180true);
add_image_size('portfolio_big'634248true);
add_image_size('portfolio_item'924390true);
add_image_size('post_thumbnail_full'924275true);

//default sizes
add_image_size('thumbnail'150150true);
add_image_size('medium'6040);
add_image_size('large'9240);

//
if( !is_admin() ){  
    
add_action'pre_get_posts',  'set_per_page'  );
}
function 
set_per_page$query ) {
    global 
$wp_the_query;
    if(
$query->is_tax('th_portfolios_cat')&&($query === $wp_the_query)){
    
$query->set'posts_per_page'1);
    }
  return 
$query;
}

?>

Agradeço desde mais a vossa ajuda.
Neps, nao precisas de deixar nenhum espaço entre o codigo que lá está e o teu.

Não podes é ter erros nas funçoes xD
Obrigado! Só faltou responder a algumas outras duvidas Happy
Explica-te melhor para conseguir ajudar-te
Aqui tens toda a info que precisas para criar um custom post type.

Tens aqui dois tutoriais muito bons que te vao ajudar a fazer o que pretendes:

http://net.tutsplus.com/tutorials/wordpr...ost-types/
http://wp.tutsplus.com/tutorials/quick-t...ost-types/

Como não tens experiência com php e wordpress recomendo-te este plugin. É um pouco caro, mas faz tudo o que pretendes e mais alguma coisa Smile
@DOWNV

Agradeço-te a tua ajuda, e aos demais. Em relação ao teu plugin, entendo a intenção, mas prefiro aprender e errar. Vou seguir os teus toturiais. Ando a aprender, como estou muito no inicio é normal estas duvidas basicas Smile
URL's de Referência