Add new page "Kariera"

This commit is contained in:
Roman Pyrih
2025-11-25 14:46:38 +01:00
parent cae1d0554e
commit 39447cda3e
7 changed files with 4487 additions and 3637 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@@ -311,4 +311,38 @@ if (!function_exists('split_text_into_spans')) {
return $html;
}
}
add_action('wp_ajax_load_more_kariera', 'load_more_kariera_callback');
add_action('wp_ajax_nopriv_load_more_kariera', 'load_more_kariera_callback');
function load_more_kariera_callback() {
$paged = isset($_POST['page']) ? intval($_POST['page']) + 1 : 1;
$query = new WP_Query([
'post_type' => 'kariera',
'posts_per_page' => get_option('posts_per_page'),
'paged' => $paged,
'orderby' => 'date',
'order' => 'DESC',
]);
if ($query->have_posts()) :
while ($query->have_posts()) : $query->the_post();
$image = get_the_post_thumbnail_url(get_the_ID(), 'medium');
$title = get_the_title();
$link = get_permalink();
get_template_part(
'inc/template-article-card', null, [
'image' => $image ?: '/wp-content/uploads/2025/08/default.jpg',
'title' => $title,
'link' => $link,
]
);
endwhile;
endif;
wp_reset_postdata();
wp_die();
}

View File

@@ -0,0 +1,137 @@
<?php
/**
* Page: Kariera
* ID: 473
*/
get_header();
$box_empty = get_field('empty');
$paged = 1;
$args = array(
'post_type' => 'kariera',
'posts_per_page' => get_option('posts_per_page'),
'paged' => $paged,
'orderby' => 'date',
'order' => 'DESC',
);
$kariera_query = new WP_Query( $args );
?>
<?php if ( $kariera_query->found_posts > 0 ) : ?>
<main id="primary" class="site-main kariera-page">
<?php
if ($kariera_query->have_posts()) :
$kariera_query->the_post();
$banner_image = get_the_post_thumbnail_url(get_the_ID(), 'large');
$banner_title = get_the_title();
$banner_link = get_permalink();
?>
<div class="box-1 <?php if ( $kariera_query->found_posts = 1 ) : ?>single<?php endif; ?>">
<div class="container">
<div class="box--wrapper">
<div class="box-bg">
<img src="<?php echo $banner_image; ?>" alt="">
</div>
<div class="row">
<div class="col col-1">
<?php get_template_part('inc/breadcrumb');?>
</div>
<div class="col col-2">
<div class="box-head">
<h2><?php echo $banner_title; ?></h2>
</div>
<a class="btn_4" href="<?php echo $banner_link; ?>">Czytaj więcej</a>
</div>
</div>
</div>
</div>
</div>
<?php endif; ?>
<?php if ( $kariera_query->found_posts >= 2 ) : ?>
<div class="box-2">
<div class="container">
<div id="box-posts-list" class="posts-list">
<?php
if ($kariera_query->have_posts()) :
while ($kariera_query->have_posts()) : $kariera_query->the_post();
$image = get_the_post_thumbnail_url(get_the_ID(), 'medium');
$title = get_the_title();
$link = get_permalink();
get_template_part(
'inc/template-article-card', null, [
'image' => $image,
'title' => $title,
'link' => $link
]
);
endwhile;
wp_reset_postdata();
endif;
?>
</div>
<?php
if ($kariera_query->found_posts > get_option('posts_per_page')) : ?>
<div class="posts-more">
<a class="btn_3" href="#" id="load-more-posts" data-page="1">
Więcej artykułów
<span class="loader"></span>
</a>
</div>
<?php endif; ?>
</div>
</div>
<?php endif; ?>
</main>
<?php else : ?>
<main id="primary" class="site-main kariera-page">
<div class="box-empty">
<div class="container">
<div class="box--wrapper">
<h2><?php echo $box_empty['title'];?></h2>
<p><?php echo $box_empty['text'];?></p>
</div>
</div>
</div>
</main>
<?php endif; ?>
<script>
jQuery(function ($) {
$('#load-more-posts').on('click', function (e) {
e.preventDefault()
var button = $(this)
var page = button.data('page')
$.ajax({
url: '<?php echo admin_url("admin-ajax.php"); ?>',
type: 'POST',
data: {
action: 'load_more_kariera',
page: page,
},
beforeSend: function () {
button.prop('disabled', true)
button.find('.loader').show()
},
complete: function () {
button.prop('disabled', false)
button.find('.loader').hide()
},
success: function (response) {
if (response) {
$('#box-posts-list').append(response)
button.data('page', page + 1)
} else {
button.text('Brak więcej artykułów').prop('disabled', true)
}
},
})
})
})
</script>
<?php get_footer();

View File

@@ -0,0 +1,65 @@
<?php
get_header();
?>
<main id="primary" class="site-main page-single-kariera">
<div class="box-1">
<div class="container">
<?php
while ( have_posts() ) :
the_post();
get_template_part( 'template-parts/content', 'kariera' );
endwhile;
?>
</div>
</div>
<?php
$args = array(
'post_type' => 'kariera',
'posts_per_page' => 3,
'orderby' => 'date',
'order' => 'DESC',
'post__not_in' => array(get_the_ID()),
);
$other_posts = new WP_Query($args);
if ($other_posts->have_posts()) :
?>
<div class="box-2">
<div class="container">
<div class="row" box-title="Blog">
<div class="box-head">
<h2>Zobacz też inne oferty</h2>
<div class="other-posts">
<?php
while ($other_posts->have_posts()) : $other_posts->the_post();
$image = get_the_post_thumbnail_url(get_the_ID(), 'medium');
$title = get_the_title();
$link = get_permalink();
get_template_part(
'inc/template-article-card', null, [
'image' => $image,
'title' => $title,
'link' => $link
]
);
endwhile;
wp_reset_postdata();
?>
</div>
</div>
</div>
</div>
</div>
<?php endif; ?>
</main><!-- #main -->
<?php
get_sidebar();
get_footer();

View File

@@ -7,12 +7,22 @@
* @package BRPP_prawo_podatki
*/
$post_type = get_post_type();
$blog_page_id = 74;
$kariera_page_id = 378;
if ( $post_type === 'kariera' ) {
$back_url = get_permalink( $kariera_page_id );
} else {
$back_url = get_permalink( $blog_page_id );
}
?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<div class="row">
<div class="col col-1">
<a class="btn_1 btn-back-page" href="/blog-brpp">
<a class="btn_1 btn-back-page" href="<?php echo esc_url( $back_url ); ?>">
<svg width="46" height="14" viewBox="0 0 46 14" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M46 7L1 7" stroke="#9E9E9E"/>
<path d="M7 1L1 7L7 13" stroke="#9E9E9E"/>