Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * The default template for displaying content
- *
- * Used for both single and index/archive/search.
- *
- * @package WordPress
- * @subpackage Twenty_Fifteen
- * @since Twenty Fifteen 1.0
- */
- ?>
- <article id="post-<?php
- the_ID();
- ?>" <?php
- post_class();
- ?>>
- <header class="entry-header">
- <?php
- $current_gallery = get_field('gallery');
- if (get_query_var('page')) {
- $current_page = get_query_var('page');
- } else {
- $current_page = 1;
- }
- //Setup pagination variables
- $splitnumber = get_field('splitnum');
- if (!empty($splitnumber)) {
- $splitnum = $splitnumber;
- }
- if (empty($splitnumber)) {
- $splitnum = 8;
- }
- $images = array(); // Set images array for current page
- $items_per_page = $splitnum; // How many items we should display on each page
- $total_items = count($current_gallery); // How many items we have in total
- $num = $total_items;
- $total_pages = ceil($total_items / $items_per_page); // How many pages we have in total
- $translated = __('Page', 'pixplus'); // Supply translatable string
- $pagenum = 1;
- //$result = get_pagenum_link($pagenum, true);
- $big = 999999999;
- $pagination = paginate_links(array(
- 'end_size' => 3,
- 'mid_size' => 1,
- 'base' => get_permalink() . '%#%' . '/',
- 'format' => '%#%',
- 'current' => $current_page,
- 'total' => $total_pages,
- 'before_page_number' => '<span class="screen-reader-text">' . $translated . ' </span>',
- 'prev_next' => 'true',
- 'link_before' => '',
- 'link_after' => '',
- 'prev_text' => __('< Previous'),
- 'next_text' => __('Next >')
- ));
- $taxonomy = 'category';
- // Get the term IDs assigned to post.
- $post_terms = wp_get_object_terms($post->ID, $taxonomy, array(
- 'fields' => 'ids'
- ));
- // Separator between links.
- $separator = ' ';
- if (!empty($post_terms) && !is_wp_error($post_terms)) {
- echo '<div class="cat-links"><ul>';
- $term_ids = implode(',', $post_terms);
- $terms = wp_list_categories(array(
- 'title_li' => '',
- 'style' => 'none',
- 'echo' => false,
- 'taxonomy' => $taxonomy,
- 'include' => $term_ids
- ));
- $terms = rtrim(trim(str_replace('<br />', $separator, $terms)), $separator);
- // Display post categories.
- echo $terms;
- echo '</ul></div>';
- }
- if (is_single()):
- the_title('<div class="page-title-number"><h1 class="entry-title">', '</h1>');
- echo '<h3>Page ' . $current_page . ' of ' . $total_pages . '</h3><button title="Copy the URL of this page to the clipboard" data-clipboard-target="#copy-me" class="url-copy"></button></div>';
- $first_page = ($total_pages == 1);
- $not_first_page = ($current_page != 1);
- $not_last_page = ($current_page != $total_pages);
- $last_page = ($total_pages != 1 && $current_page >= $total_pages);
- if ($last_page) {
- echo '<p>Made this origami? Leave a comment & submit your photo <a href="#comments">here</a>.</p>';
- }
- $dudeurl = get_post_meta(get_the_ID(), 'dude_url', true);
- $dudebutt = get_permalink($dudeurl);
- if ($not_last_page) {
- echo '<p>Made this origami? Leave a comment & submit your photo on the last page <a href="' . $dudebutt . $total_pages . '#comments">here</a>.</p>';
- }
- if ($total_pages == 1) {
- echo '<p>Made this origami? Leave a comment & submit your photo <a href="#comments">here</a>.</p>';
- }
- endif;
- ?>
- <div class="linky"><input id="copy-me" value="<?php echo $dudebutt; echo $current_page ?>/"></div>
- </header><!-- .entry-header -->
- <div class="entry-content">
- <?php
- if (function_exists('social_warfare')) {
- social_warfare();
- }
- echo '<div class="gallery-wrapper">';
- //Get current page
- if ($current_page === 1) {
- twentyfifteen_post_thumbnail();
- $key_3_value = get_post_meta(get_the_ID(), 'cat-title', true);
- // Check if the custom field has a value.
- if (!empty($key_3_value)) {
- echo '<h3><strong>';
- echo $key_3_value;
- echo '</strong></h3>';
- }
- echo '<div class="level-meta">';
- $key_1_value = get_post_meta(get_the_ID(), 'level', true);
- // Check if the custom field has a value.
- if (!empty($key_1_value)) {
- echo '<p>Level: ';
- echo $key_1_value;
- echo '</p>';
- }
- $key_2_value = get_post_meta(get_the_ID(), 'copyright', true);
- // Check if the custom field has a value.
- if (!empty($key_2_value)) {
- echo '<p>Copyright: ';
- echo $key_2_value;
- echo ' <a title="more info/report mistake" href="https://origami.guide/about-us-copyright-information/">?</a></p>';
- }
- echo '</p></div>';
- /* translators: %s: Name of current post */
- the_content(sprintf(__('Continue reading %s', 'twentyfifteen'), the_title('<span class="screen-reader-text">', '</span>', false)));
- echo do_shortcode('[sc name="moonad"]');
- ?>
- <?php
- if (!empty($key_3_value)) {
- echo '<h3><strong>';
- echo $key_3_value;
- echo ' Instructions</strong></h3>';
- }
- $cattitle = get_field('cat-title');
- $video = get_field('video');
- if ($video && $cattitle) {
- echo '<p></p><p>Scroll down to follow the photo tutorial for the <span style="text-transform: capitalize">' . $cattitle . '</span>, there is also a video tutorial available at the end (on the last page).</p>';
- }
- }
- $starting_point = (($current_page - 1) * $items_per_page); // Get starting point for current page
- // Get elements for current page
- if ($current_gallery) {
- $images = array_slice($current_gallery, $starting_point, $items_per_page);
- }
- $i = $starting_point;
- if ($images) {
- $n = 4; //or whatever you want to chunk into
- $ny = 8;
- echo '<section class="gallery-post"><ol class="post-gal">'; //always open one
- $lcv = 1; // loop count variable
- $lcv2 = 1;
- $starting_pointy = (($current_page - 1) * $items_per_page + 1);
- foreach ($images as $image) {
- $tot_stuff = $starting_pointy++;
- $size = 'large';
- echo '<li>
- <div class="linky"><input id="copy-me' . $tot_stuff . '" value="' . $dudebutt . $current_page . '#' . $tot_stuff . '" id="myInput" ></div>
- <span class="count" id="' . $tot_stuff . '">' . $tot_stuff . '</span>
- <div class="step-image">
- <span class="link-step">
- <button title="Copy the URL of this step to the clipboard" data-clipboard-target="#copy-me' . $tot_stuff . '" class="url-copy"></button></span><a href="' . $image['url'] . '">' . wp_get_attachment_image($image['ID'], $size, true, array(
- "class" => "nopin mobx"
- )) . '</a></div>';
- if (get_field('auto_count_captions') == 'yes') {
- echo '<p><span class="">' . $tot_stuff . '. </span>' . $image['caption'] . '</p></li>';
- } else {
- echo '<p>' . $image['caption'] . '</p></li>';
- }
- if ($lcv++ % $n == 0 && $lcv < $num) { // every Nth item, unless we're done
- echo do_shortcode('[sc name="post ad banner"]');
- }
- if ($lcv2++ % $ny == 0 && $lcv2 < $num) { // every Nth item, unless we're done
- }
- }
- echo "</ol></section>"; //always close the last one.
- }
- echo '</ol></section>';
- if ($current_page >= $total_pages) {
- $cattitle = get_field('cat-title');
- $video = get_field('video');
- if ($video && $cattitle) {
- echo '<section class="gallery-post"><div id="video"><h2>Video Tutorial</h2>';
- echo '<p>A video tutorial for the <span style="text-transform: capitalize">' . $cattitle . '</span> is available:</p>';
- echo '<iframe width="720" height="405" src="https://www.youtube.com/embed/' . $video . '?rel=0&controls=1&showinfo=0" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe></div></section>';
- }
- $conclusion = get_field('conclusion');
- $conclusioncol = get_field('conclusion-bg');
- if ($conclusion) {
- echo '<div class="conclusion" style="background:' . $conclusioncol . '!important;"><h3 style=" color:white; margin:10px 0 0 0;">Your ' . $cattitle . ' is Complete!</h3><p>' . $conclusion . '</p><p>Made this origami? Leave a comment & submit your photo <a href="#comments">here</a>.</p>';
- }
- ?>
- <?php
- echo '</div>';
- }
- if ($pagination) {
- echo '<div class="pagination-wrapper">';
- if (($not_first_page) & ($total_pages >= 3)) {
- echo '<a href="' . $dudebutt . '"> << FIRST</a> ';
- }
- echo $pagination;
- if (($not_last_page) & ($total_pages >= 3)) {
- echo ' <a href="' . $dudebutt . $total_pages . '">LAST >> </a>';
- }
- echo '</div></div>';
- }
- ?>
- <?php
- if (function_exists('social_warfare')) {
- social_warfare();
- }
- ?>
- <div class="tags">
- <?php
- echo show_tags_except_hidden();
- ?>
- </div>
- <?php
- echo do_shortcode('[sc name="gbannerresponsive"]');
- echo "<h3>What To Fold Next?</h3><ul class='prev-next'>";
- // Get primary (Yoast) term if it is set
- $currentID = get_the_ID();
- $category = get_the_category();
- $category_display = '';
- $category_slug = '';
- if (class_exists('WPSEO_Primary_Term')) {
- // Show the post's 'Primary' category, if this Yoast feature is available, & one is set
- $wpseo_primary_term = new WPSEO_Primary_Term('category', get_the_id());
- $wpseo_primary_term = $wpseo_primary_term->get_primary_term();
- $term = get_term($wpseo_primary_term);
- if (is_wp_error($term)) {
- // Default to first category (not Yoast) if an error is returned
- $category_display = $category[0]->term_id;
- $category_slug = $category[0]->slug;
- } else {
- // Set variables for category_display & category_slug based on Primary Yoast Term
- $category_id = $term->term_id;
- $category_term = get_category($category_id);
- $category_display = $term->term_id;
- $category_slug = $term->slug;
- }
- } else {
- // Default, display the first category in WP's list of assigned categories
- $category_display = $category[0]->term_id;
- $category_slug = $category[0]->slug;
- }
- previous_post_link_plus(array(
- 'order_by' => 'menu_order',
- 'order_2nd' => 'post_date',
- 'in_cats' => $category_display,
- 'meta_key' => '',
- 'post_type' => '',
- 'loop' => true,
- 'end_post' => false,
- 'in_same_tax' => 'category',
- 'thumb' => 'thumbnail',
- 'max_length' => 0,
- 'format' => '« %link ',
- 'link' => '%title',
- 'date_format' => '',
- 'tooltip' => '%title',
- 'in_same_cat' => true,
- 'before' => '<li>',
- 'after' => '</li>'
- ));
- next_post_link_plus(array(
- 'order_by' => 'menu_order',
- 'order_2nd' => 'post_date',
- 'in_cats' => $category_display,
- 'meta_key' => '',
- 'post_type' => '',
- 'loop' => true,
- 'end_post' => false,
- 'in_same_tax' => 'category',
- 'thumb' => 'thumbnail',
- 'max_length' => 0,
- 'format' => '%link »',
- 'link' => '%title',
- 'date_format' => '',
- 'tooltip' => '%title',
- 'in_same_cat' => true,
- 'before' => '<li>',
- 'after' => '</li>'
- ));
- echo '</ul>';
- ?>
- <?php
- if ($current_page >= $total_pages) {
- if (comments_open() || get_comments_number()) {
- comments_template();
- }
- }
- echo do_shortcode('[sc name="gbannerresponsive"]');
- ?>
- </div><!-- .entry-content -->
- <footer class="entry-footer">
- </footer><!-- .entry-footer -->
- </article><!-- #post-## -->
Advertisement
Add Comment
Please, Sign In to add comment