Paginar links com "feios" e "bonitos" Permalinks?
1 responda
- votos
Então,parece que épossívelfazeressafunçãotrabalhar compermalinks "feios"e "bonitos".Aquiestá o código:
<?php
global $wp_query;
//structure of "format" depends on whether we're using pretty permalinks
if( get_option('permalink_structure') ) {
$format = '?paged=%#%';
} else {
$format = 'page/%#%/';
}
$big = 999999999; // need an unlikely integer
$base = $format =='?paged=%#%' ? $base = str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ) : $base = @add_query_arg('paged','%#%');
echo paginate_links( array(
'base' => $base,
'format' => $format,
'current' => max( 1, $paged ),
'total' => $wp_query->max_num_pages,
'prev_text' => esc_html__( 'Prev', 'domain' ),
'next_text' => esc_html__( 'Next', 'domain' ),
'end_size' => 1,
'mid_size' => 1,
) );
?>
Espero que ajude alguém;)
So it look's like it is possible to make this function work with “ugly” and “pretty” permalinks. Here is the code:
<?php
global $wp_query;
//structure of "format" depends on whether we're using pretty permalinks
if( get_option('permalink_structure') ) {
$format = '?paged=%#%';
} else {
$format = 'page/%#%/';
}
$big = 999999999; // need an unlikely integer
$base = $format =='?paged=%#%' ? $base = str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ) : $base = @add_query_arg('paged','%#%');
echo paginate_links( array(
'base' => $base,
'format' => $format,
'current' => max( 1, $paged ),
'total' => $wp_query->max_num_pages,
'prev_text' => esc_html__( 'Prev', 'domain' ),
'next_text' => esc_html__( 'Next', 'domain' ),
'end_size' => 1,
'mid_size' => 1,
) );
?>
Hope it will help someone ;)
Seeutiver "bonito"permalinkspermitido quemeu códigofuncioneparapáginasestáticas (funcionará se apáginaestiver definida como "homepage" ou "páginanormal"). Masmeu código quebra seeu usar aestrutura "Padrão Permalink".
Eutenhoisso até agora (trabalhandobem com "belospermalinks",mas quebra com "Permalinksfeios"):
Épossívelterpaginaçãonumeradapara ambos (feioe bonitopermalinks)?