Skip to content

Instantly share code, notes, and snippets.

@fernandopetry
Last active August 29, 2015 14:27
Show Gist options
  • Save fernandopetry/da09def17f77dac22b1f to your computer and use it in GitHub Desktop.
Save fernandopetry/da09def17f77dac22b1f to your computer and use it in GitHub Desktop.
snippets para o wordpress
<?php while (have_posts()) : the_post(); ?>
<h1><?php the_title(); ?></h1>
<div id="texto">
<?php the_content('Read the rest of this entry &raquo;'); ?>
<small><?php the_time('F jS, Y') ?> por <?php the_author() ?> </small>
</div>
<?php endwhile; ?>
UPDATE wp_options SET option_value = replace(option_value, 'http://www.oldurl', 'http://www.newurl') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = replace(guid, 'http://www.oldurl','http://www.newurl');
UPDATE wp_posts SET post_content = replace(post_content, 'http://www.oldurl', 'http://www.newurl');
UPDATE wp_postmeta SET meta_value = replace(meta_value,'http://www.oldurl','http://www.newurl');
<?php
/*
Template Name: [nome do template]
*/
get_header();
// conteudo do da pagina
get_footer();
?>
Para formularios de contato
=> Caldera Forms
Arquivos basicos para a criação de um theme
- functions.php
- index.php
- header.php
- footer.php
- style.css
- screenshot.png
- opcional
- tambem é possivel criar modelos de pagina para isso criar um arquivo exemplo: pagina-interna.php
<!-- CONTEUDO: footer.php (antes do fechamento do body) -->
<?php wp_footer(); ?>
</body>
<!-- CONTEUDO: pagina-interna.php -->
<?php
/*
Template Name: [nome do template]
*/
get_header();
// conteudo do da pagina
get_footer();
?>
<!-- CONTEUDO: style.css -->
/*
Theme Name: [nome do tema]
Theme URI: [site do tema]
Author: [nome do autor]
Author URI: [site o autor]
Description: [descricao do tema]
Version: [versao do thema]
*/
<!-- html dinamico -->
<html <?php language_attributes(); ?>>
<!-- charset dinamico -->
<meta charset="<?php bloginfo( 'charset' ); ?>">
<!-- titulo da pagina -->
<title>
<?php
if (is_home()) {
echo bloginfo() . " | " . get_bloginfo('description');
} else {
wp_title('|', true, 'right');
bloginfo();
}
?>
</title>
<link rel="profile" href="http://gmpg.org/xfn/11">
<link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>">
<link rel="stylesheet" type="text/css" media="all" href="<?php bloginfo( 'stylesheet_url' ); ?>" />
<!-- antes de fechar o head -->
<?php wp_head(); ?>
</head>
<!-- body class -->
<body <?php body_class(); ?>>
<?php
###############################################################
## Retirando a metatag WordPress Generator
###############################################################
remove_action('wp_head', 'wp_generator');
###############################################################
# ALGUMAS CONFIGURAÇÔES
###############################################################
###############################################################
# URLs
###############################################################
// url home
echo esc_url( home_url( '/' ) );
// url completa da raiz do template
echo get_template_directory_uri();
###############################################################
# Adiciona menus personalizados para ser utilizado no template
###############################################################
// no arquivo function.php
add_action('init', 'register_my_menus');
function register_my_menus() {
register_nav_menus(
array(
'menu-topo' => __('Menu Topo'),
'menu-coluna-lateral' => __('Menu Coluna Lateral'),
'menu-rodape' => __('Menu Rodapé')
)
);
}
// local onde deseja ativar o menu no template
// Codex: https://codex.wordpress.org/Function_Reference/wp_nav_menu
wp_nav_menu(
array(
'theme_location' => 'menu-topo',
'items_wrap' => '<ul class="nav navbar-nav navbar-right">%3$s</ul>'
)
);
###############################################################
# Adicionando suporte a imagens destacadas no template
###############################################################
add_theme_support('post-thumbnails');
###############################################################
# Suporte ao menu ativo
###############################################################
add_filter('nav_menu_css_class' , 'special_nav_class' , 10 , 2);
function special_nav_class ($classes, $item) {
if (in_array('current-menu-item', $classes) ){
$classes[] = 'active ';
}
return $classes;
}
###############################################################
# Tamanho de miniatura personaliza
###############################################################
add_action( 'after_setup_theme', 'thumb_medio' );
function thumb_medio(){
add_image_size( 'thumb_medio', 570, 311, true );
}
<?php
define('WP_DEBUG', true); // ativando o debug, não usar em producao
define('WP_POST_REVISIONS', false ); // desativar o historico de posts alterados
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment