Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4120778
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T23:15:58+00:00 2026-05-20T23:15:58+00:00

I am creating a wordpress theme for a record label. One aspect is the

  • 0

I am creating a wordpress theme for a record label. One aspect is the video gallery.

I created the gallery using a custom post type called ‘videos’. The code below is what I placed in my functions.php file to set up the post type:

add_action( 'init', 'create_my_post_types' );
        function create_my_post_types() {

register_post_type( 'videos',
        array(
            'labels' => array(
                'name' => __( 'Videos' ),
                'singular_name' => __( 'Video' ),
                'add_new' => 'Add New Video',
                'edit' => 'Edit Video'
            ),
            'public' => true,
            'exclude_from_search' => false,
            'supports' => array( 'title', 'editor', 'thumbnail','page-attributes','excerpt' ),
            'rewrite' => array( 'slug' => 'videos', 'with_front' => false ),

        ));
    }

I also created a custom taxonomy called ‘artists’ so I can assign the artist name to each video I upload.

 add_action( 'init', 'create_videos_taxonomies' );

    function create_videos_taxonomies() {

        register_taxonomy(
            'artist',
            'videos',
            array( 
                    'hierarchical' => false,
                    'label' => 'Artist',
                    'query_var' => true,
                    'show_tagcloud' => true,
                    'show_ui' => true,
                    'rewrite'=>array('slug' => 'artists', 'with_front' => false)
                  )
            );
        }

At this point, everything works fine on the backend and the video page returns all of the videos successfully.

On another area of my website, I have pages for every single artist. On any one of these artist pages, i would like to be able to loop through all of the videos in the custom post type I created, and only return results in a given taxonomy. Below is my code to loop through a custom post type:

<?php $loop = new WP_Query( array( 'post_type' => 'videos', 'post_child' => 0, 'posts_per_page' => 5 ) ); ?>
    <?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
<?php the_post_thumbnail( 'video' ); ?>
<?php the_content(); ?> 
<?php endwhile; ?>

This successfully loops through the videos, and returns the 5 most recent. I need this to loop through all the videos with a specific taxonomy slug or ID. For instance, I created a taxonomy called ‘Smash Palace’ and it has a slug of ‘smash-palace’ and an id of ’17’. Any idea how I can loop though this custom post type and only return results in a given taxonomy?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T23:15:59+00:00Added an answer on May 20, 2026 at 11:15 pm

    I feel like you should be able to query based on post_type and taxonomy like this:

    <?php $loop = new WP_Query( array( 'post_type' => 'videos', 'taxonomy_name' => $term, 'post_child' => 0, 'posts_per_page' => 5 ) ); ?>
    

    found similar question on SO:
    WordPress, WP_Query with custom taxonomy and custom post type

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi I am creating a wordpress custom page theme, I have included the code.
I am creating a child theme in Wordpress using the TwentyTen theme as a
I am relatively new to wordpress, I am creating a custom theme, and so
So I am stripping down wordpress and using it as a simple photo/video gallery
For creating wordpress themes, people usually follow one of these two methods Design Mockup
I'm using svn for the first time, to maintain a custom version of Wordpress.
I would like to restrict the fields while creating a new post in WordPress.
I'm creating a Wordpress plugin and, being a newbie in the development on this
Our WordPress 2.8.6 installation is returning multiple different errors when trying to edit theme
I am running an ecommerce theme on wordpress on a hostgator server, and coming

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.