• Resolved Greg Robertson

    (@517design)


    I’m new and this is probably simple for most of you.

    I have a section in my dashboard called “services”
    I have 4 services
    I have 2 categories for these services: residential and commercial
    2 of the 4 services have the category “residential”, and the other 2 “commercial”

    As it is now my services page is pulling up all 4 services.

    Question: what code do I add, to show only the 2 services with the category of residential?

    Here is my current code on the archive-service.php page

    `<?php
    $paged = ( get_query_var( ‘paged’ ) ) ? absint( get_query_var( ‘paged’ ) ) : 1;
    $args = array(
    ‘post_type’ => ‘service’,
    ‘posts_per_page’ => 8,
    ‘paged’ => $paged,

    );
    $wp_query = new WP_Query($args);
    while($wp_query->have_posts()) : $wp_query->the_post();
    ?>`

    https://936.678.myftpupload.com/services/

    That’s all, Thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi @517design

    Once try this code instead:
    <?php
    $paged = ( get_query_var( ‘paged’ ) ) ? absint( get_query_var( ‘paged’ ) ) : 1;
    $args = array(
    ‘post_type’ => ‘service’,
    ‘category_name’ => ‘residential’,
    ‘posts_per_page’ => 8,
    ‘paged’ => $paged,

    );
    $wp_query = new WP_Query($args);
    while($wp_query->have_posts()) : $wp_query->the_post();
    ?>`

    Thanks and CHEERS!!!

    Thread Starter Greg Robertson

    (@517design)

    Thanks!! but I already got it.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘adding a category to post_type’ is closed to new replies.