WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Filter out a CP Archive from a specific Cust. Tax (2 posts)

  1. MCM
    Member
    Posted 1 year ago #

    Context:
    CPT (Custom Post Type) = Articles
    CT (Custom Tax) = Writers
    CT (Custom Tax) = Profiles

    Description:
    The desired flow would be as follows:

    1. User Clicks on Articles and is shown all the latest articles (Done) using a archive-articles.php in my child theme.

    2. User then clicks on Writer A from the CT Widget and is show that writers latest articles (Done)

    3. Now, I also want to include a profile for each writer AT THE TOP of this 'latest articles for writer' page.

    Problem:

    Now, being a CPT I found a plugin to make it sticky posts for CPT.

    Requirement 1: However, on the archive-articles.php I would need - on showing the latest articles - to exclude ALL Articles "tagged" in 'Profiles'

    Requirement 2: (3) On this page, it must show his latest articles with the profile "tagged" Article at the top.

    Ideas:
    I have tried the following code after googling in attempt to solve problem 1, and placed it inside my archive-articles.php file however, it only shows the profile posts! How does that work?

    $myquery['tax_query'] = array(
        array(
            'taxonomy' => 'writers',
            'terms' => array('profile'),
            'field' => 'slug',
    	'operator' => 'NOT IN',
        ),     
    
    );
    
    query_posts($myquery);

    Problem 2: If I can get the above feature to work then this would happen by default.

  2. MCM
    Member
    Posted 1 year ago #

    Dropping found the solution.

    I need an Array of an Array

    $query->set( 'tax_query', array(
    			array(
    				'taxonomy' => 'qriters',
    				'field' => 'slug',
    				'terms' => array( 'profiles' ),
    				'operator' => 'NOT IN',
    			)));

Topic Closed

This topic has been closed to new replies.

About this Topic