function cwPaging() {
// Don't print empty markup if there's only one page.
if ( $GLOBALS['wp_query']->max_num_pages < 2 ) {
return;
}
$paged = get_query_var( 'paged' ) ? intval( get_query_var( 'paged' ) ) : 1;
$pagenum_link = html_entity_decode( get_pagenum_link() );
$query_args = array();
$url_parts = explode( '?', $pagenum_link );
if ( isset( $url_parts[1] ) ) {
wp_parse_str( $url_parts[1], $query_args );
}
$pagenum_link = remove_query_arg( array_keys( $query_args ), $pagenum_link );
$pagenum_link = trailingslashit( $pagenum_link ) . '%_%';
$format = $GLOBALS['wp_rewrite']->using_index_permalinks() && ! strpos( $pagenum_link, 'index.php' ) ? 'index.php/' : '';
$format .= $GLOBALS['wp_rewrite']->using_permalinks() ? user_trailingslashit( 'page/%#%', 'paged' ) : '?paged=%#%';
// Set up paginated links.
$links = paginate_links( array(
'base' => $pagenum_link,
'format' => $format,
'total' => $GLOBALS['wp_query']->max_num_pages,
'current' => $paged,
'mid_size' => 3,
'add_args' => array_map( 'urlencode', $query_args ),
'prev_text' => __( '← Previous', 'yourtheme' ),
'next_text' => __( 'Next →', 'yourtheme' ),
'type' => 'list',
) );
if ( $links ) :
return '
';
endif;
}
function wpd_testimonials_query( $query ){
global $website;
if( ! is_admin()
&& ( $query->is_post_type_archive( 'produs' ) || $query->is_post_type_archive( 'post' ) || ( $query->is_category ) )
&& ( $query->is_main_query()) ){
$query->set( 'posts_per_page', 12 );
}
}
add_action( 'pre_get_posts', 'wpd_testimonials_query' );
/**
to add your new custom post type to WordPress category and tag archives
*/
function my_cptui_add_post_types_to_archives( $query ) {
// We do not want unintended consequences.
if ( is_admin() || ! $query->is_main_query() ) {
return;
}
if ( is_category() || is_tag() && empty( $query->query_vars['suppress_filters'] ) ) {
$cptui_post_types = cptui_get_post_type_slugs();
$query->set(
'post_type',
array_merge(
array( 'post' ),
$cptui_post_types
)
);
}
}
add_filter( 'pre_get_posts', 'my_cptui_add_post_types_to_archives' );
function THEME_SLUG_posts_add_rewrite_rules( $wp_rewrite )
{
$new_rules = [
'blog/page/([0-9]{1,})/?$' => 'index.php?post_type=post&paged='. $wp_rewrite->preg_index(1),
'blog/(.+?)/?$' => 'index.php?post_type=post&name='. $wp_rewrite->preg_index(1),
];
$wp_rewrite->rules = $new_rules + $wp_rewrite->rules;
return $wp_rewrite->rules;
}
add_action('generate_rewrite_rules', 'THEME_SLUG_posts_add_rewrite_rules');
function THEME_SLUG_posts_change_blog_links($post_link, $id=0){
$post = get_post($id);
if( is_object($post) && $post->post_type == 'post'){
return home_url('/blog/'. $post->post_name.'/');
}
return $post_link;
}
add_filter('post_link', 'THEME_SLUG_posts_change_blog_links', 1, 3);
gravity_form_enqueue_scripts( 1, true ); ?>
Contact – Sintezis
if (get_post_type(get_the_id())=='produs'){
$category = get_the_category(get_the_id());
//dump ($category);
$category = $category[0];
if (!empty($category->parent)){
$parent_category = get_category($category->parent);
$category_class = $parent_category->slug;
}
else $category_class = $category->slug;
}else {
if (strpos($_SERVER['REQUEST_URI'], 'categorie') !== false){
$pos = 2;
}
else $pos = 1;
$parts = explode('/', $_SERVER['REQUEST_URI']);
$category_class=$parts[$pos];
}
?>
Completează formularul de mai jos și iți vom răspunde în cel mai scurt timp.