Podrška » Problemi » Custom page template displayed by category

  • I’m making portfolio website. Made custom template that user can choose when creating new page. Made custom post type Portfolio, and added work items in it. But right now when I make new page and choose that template, added items are just showing all items on every new page. How do I combine page template with category? So on each new page created user can give that page custom template and category. Because it is custom template adding category backed will not work, cause I want user to have ability creating new page and append category to it and then that page will display only items with that category slug. Tried so many solutions with no luck, so help needed!

Pregledavate 2 odgovora - 1 do 2 (od ukupno 2)
  • <?php
    /**
     * Template Name: Portfolio
     * Description: Page portfolio template with photos
     *
     * This is the template that displays all pages by default.
     * Please note that this is the WordPress construct of pages
     * and that other 'pages' on your WordPress site may use a
     * different template.
     *
     * @link https://codex.wordpress.org/Template_Hierarchy
     *
     * @package
     */
    
    get_header(); ?>
    
        <div class="row">
    
            <ul class="grid">
    
                <?php $loop = new WP_Query(array(
                    'post_type' => 'portfolio_photos',
                    'orderby'   => 'post_id',
                    'order'     => 'ASC'));
    
                    while ($loop->have_posts()) : $loop->the_post(); ?>
    
                    <?php $portfolio_photos = get_field('portfolio_photos'); ?>
    
                    <li>
    
                        <a data-lightbox-gallery="gallery1" href="<?php echo $portfolio_photos['url']; ?>">
                            <img src="<?php echo $portfolio_photos['url']; ?>">
                        </a>
    
                    </li>
    
                <?php endwhile;
    
                wp_reset_query(); ?>
    
            </ul>
    
        </div>
    
    <?php
    
    get_footer();

    Hey, this is a croatian subforum, so it would be better if you’d repost this on the english speaking forum https://wordpress.org/support/ — you might get more valuable feedback there. Thanks.

Pregledavate 2 odgovora - 1 do 2 (od ukupno 2)
  • The topic ‘Custom page template displayed by category’ is closed to new replies.