Skip to content

Instantly share code, notes, and snippets.

<?php
function inicio_1() {
echo '<li><a href="'.get_home_url().'">Início</a></li>';
}
function shop_p() {
echo '<li><a href="'.get_permalink( wc_get_page_id( 'shop' ) ).'">Shop</a></li>';
}
@LeoLopesWeb
LeoLopesWeb / disable-comments.php
Created June 7, 2018 16:41
add on functions.php
// Add to existing function.php file
// Disable support for comments and trackbacks in post types
function df_disable_comments_post_types_support() {
$post_types = get_post_types();
foreach ($post_types as $post_type) {
if(post_type_supports($post_type, 'comments')) {
remove_post_type_support($post_type, 'comments');
remove_post_type_support($post_type, 'trackbacks');
}
}
echo get_the_post_thumbnail_url(get_the_ID(),'medium'); // thumbnail, full
ou
echo wp_get_attachment_url( get_post_thumbnail_id( $saved_post_id ) );
ou
echo '<img src="'.get_the_post_thumbnail( $post_id, 'medium' ).'">';
function lista_paginas($atts) {
ob_start();
$a = shortcode_atts( array(
'categoria' => '',
), $atts );
echo'<div class="">';
global $post;
$args = array(
'post_type' => 'page',
Host do SMTP: localhost
Porta SMTP: 587
Criptografia: TLS
Autenticação: true
SMTP Username: [email protected]
SMTP Password: senha do email
function fontawesome() {
wp_enqueue_style( 'fontawesome', 'https://use.fontawesome.com/releases/v5.0.13/css/all.css', array(), '1.0', 'all');
}
add_action( 'wp_enqueue_scripts', 'fontawesome' );
// caminho do diretório do tema
<img src="<?php echo get_stylesheet_directory_uri() ?>/images/.jpg" />
<img src="<?php bloginfo('template_directory'); ?>/images/.jpg" />
// pegar url imagem destacada
$thumb = wp_get_attachment_image_src( get_post_thumbnail_id(), 'thumbnail' );
$thumb[0]
// archive custom post type e taxonomy
if (is_tax( 'categoria-embarcacao' )):
add_filter( 'pre_get_posts', 'tgm_io_cpt_search' );
/**
* This function modifies the main WordPress query to include an array of
* post types instead of the default 'post' post type.
*
* @param object $query The original query.
* @return object $query The amended query.
*/
function tgm_io_cpt_search( $query ) {
if ( $query->is_search ) {
$url = parse_url($_SERVER['REQUEST_URI']);
if(isset($url['query'])) :
//code
endif;