Forum Replies Created

Viewing 3 replies - 1 through 3 (of 3 total)
  • dreadstar42

    (@dreadstar42)

    when I used the code, I would get 10 items from what seemed to be limited to the first custom post type listed in:
    $query->set( ‘post_type’, array( ‘post’, ‘custom1′,’custom2’ ) );

    When I remove the code I do get 2 post items which were tagged with the tag in question. And testing for a tag that is only on custom type entries come up with a page not found.

    this definitely doesnt seem like a problem with your plugin, but the suggested code does not seem to work either. Any help would be appreciated.

    dreadstar42

    (@dreadstar42)

    added the code to my functions.php of my theme:

    function add_custom_post_types( $query ) {
    	if ( $query->is_search || $query->is_tag || $query->is_category ) {
    		// print_r($query->query_vars);
    		$query->set( 'post_type', array( 'post', 'custom1','custom2' ) );
    		// echo "after set<br>";
    		print_r($query->query_vars);
    	}
    }
    add_action( 'pre_get_posts', 'add_custom_post_types' );

    also, only one item of type custom1 is returned when I select a tag. Here is the print_r of the $query_vars on the Tag Archive page:

    Array
    (
        [tag] => lagarde
        [error] =>
        [m] =>
        [p] => 0
        [post_parent] =>
        [subpost] =>
        [subpost_id] =>
        [attachment] =>
        [attachment_id] => 0
        [name] =>
        [static] =>
        [pagename] =>
        [page_id] => 0
        [second] =>
        [minute] =>
        [hour] =>
        [day] => 0
        [monthnum] => 0
        [year] => 0
        [w] => 0
        [category_name] =>
        [cat] =>
        [tag_id] =>
        [author] =>
        [author_name] =>
        [feed] =>
        [tb] =>
        [paged] => 0
        [comments_popup] =>
        [meta_key] =>
        [meta_value] =>
        [preview] =>
        [s] =>
        [sentence] =>
        [fields] =>
        [menu_order] =>
        [category__in] => Array
            (
            )
    
        [category__not_in] => Array
            (
            )
    
        [category__and] => Array
            (
            )
    
        [post__in] => Array
            (
            )
    
        [post__not_in] => Array
            (
            )
    
        [tag__in] => Array
            (
            )
    
        [tag__not_in] => Array
            (
            )
    
        [tag__and] => Array
            (
            )
    
        [tag_slug__in] => Array
            (
                [0] => lagarde
            )
    
        [tag_slug__and] => Array
            (
            )
    
        [post_parent__in] => Array
            (
            )
    
        [post_parent__not_in] => Array
            (
            )
    
        [author__in] => Array
            (
            )
    
        [author__not_in] => Array
            (
            )
    
        [post_type] => Array
            (
                [0] => post
                [1] => custom1
                [2] => custom2
            )
    
    )

    dreadstar42

    (@dreadstar42)

    Hi Benohead,
    where would i add the code you provide above? I too am using a couple of custom post types.

    Thanks

Viewing 3 replies - 1 through 3 (of 3 total)