• I have created a page template for a website where each page will display certain posts from relevant categories. Rather than create multiple page templates and use the (‘cat=1,2’) as seen in the code below:

    <?php $custom_query = new WP_Query(‘cat=1,2’);
    while($custom_query->have_posts()) : $custom_query->the_post(); ?>

    Is there a way that I can insert a code (‘cat=[CODE HERE]’) that will let me create a custom field so when I create a new page in the backend, I can scroll down to custom fields choose the appropriate one and insert “1,2” so that page only displays post categories ID 1 and 2.

    Then on another new page I can go to the same custom field and choose ID 17 and 22 which then displays the relevant categories on the page.

    Hope this makes sense and thank you in advance

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Add custom fields to custom page tempalte’ is closed to new replies.