Popular post

About

Blog sobre diseño y desarrollo web.
Códigos o enlaces que me han sido útiles en mi trabajo como desarrolladora web :)
Mostrando entradas con la etiqueta wordpress. Mostrar todas las entradas
Mostrando entradas con la etiqueta wordpress. Mostrar todas las entradas

viernes, 30 de diciembre de 2016

WordPress Custom Post Type Pagination Issue

Código para el template

<!-- Archivo de cabecera global de Wordpress -->
<?php get_header();
/**
 * Template Name: Portfolio
 **/
?>
<?php get_header(); ?>

<h2>Posts</h2>

<?php

$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;

query_posts(array(
'post_type'      => 'portfolio', // You can add a custom post type if you like
'paged'          => $paged,
'posts_per_page' => 2
));

if ( have_posts() ) : ?>

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

 <article class="loop">

<div class="thumbnail">
 <?php
 if ( has_post_thumbnail() ) {
the_post_thumbnail('square-thumb');
 }
 ?>
</div>
<div class="content">

<h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
<small>Publicado el <?php the_time('j/m/Y') ?> por <?php the_author_posts_link() ?> | <?php the_taxonomies( $args ); ?>

  </small>


</div>
      </article>
<?php endwhile; ?>

<?php my_pagination(); ?>

<?php else : ?>

    <p><?php _e( 'Ups, no hemos encontrado ningún post.' ); ?></p>

<?php endif; ?>

<?php get_footer(); ?>




Código en fuctions.php

//paginacion para query loop
if ( ! function_exists( 'my_pagination' ) ) :
function my_pagination() {
global $wp_query;

$big = 999999999; // need an unlikely integer

echo paginate_links( array(
'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
'format' => '?paged=%#%',
'current' => max( 1, get_query_var('paged') ),
'total' => $wp_query->max_num_pages
) );
}
endif;

Tuve un problema y me daba error 404 la paginación.. la respuesta... llama a tu página de manera diferente a tu custom post type.

http://www.qwerty-design.co.uk/2015/02/wordpress-custom-post-type-pagination-issue/

miércoles, 11 de mayo de 2016

Eliminar la barra lateral en categorias en el theme Divi

Añadir en functions.php

// eliminamos la clase et_right_sidebar de la
add_filter('body_class', 'remove_a_body_class', 20, 2);
function remove_a_body_class($wp_classes) {
if(  is_archive() ) :
      foreach($wp_classes as $key => $value) {
      if ($value == 'et_right_sidebar') unset($wp_classes[$key]);
      }
endif;
return $wp_classes;
}

/* Añadir una nueva clase a body_class sólo en archivo

function my_class_names($classes) {
// add 'class-name' to the $classes array
if( is_archive() ) $classes[] = 'category_page';
// return the $classes array
return $classes;
}
add_filter('body_class','my_class_names');*/

lunes, 27 de abril de 2015

Enlazar el estilo del tema principal a tu child theme a través de function.php

// Faster than @import
add_action( 'wp_enqueue_scripts', 'my_child_theme_scripts' );
function my_child_theme_scripts() {
    wp_enqueue_style( 'parent-theme-css', get_template_directory_uri() . '/style.css' );
}

Cargar más estilos en tu child-theme de wordpress

Añadir a function.php de child theme

/** Add scripts & styles*/
add_action( 'wp_enqueue_scripts', 'load_fontawesome_style', 999 );
function load_fontawesome_style() {
      wp_register_style( 'font-awesome',  get_stylesheet_directory_uri() . 'font-awesome-4.3.0/css/font-awesome.css' );
      wp_enqueue_style( 'font-awesome' );
}

viernes, 20 de febrero de 2015

Childtheme - Reescribir un shortcode del tema padre

add_action( 'after_setup_theme', 'remove_add_shortcode' );
function remove_add_shortcode() {
remove_shortcode( 'shortcode' );
add_shortcode( 'shortcode', 'child_shortcode' );
}

function child_shortcode()
{


}