• Resolved yephy

    (@yephy)


    When the QUERY LOOP module uses taxonomies to filter articles, it cannot effectively display the taxonomy list for custom article types.

Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Support fernandoazarcon2

    (@fernandoazarcon2)

    Hi @yephy,

    To clarify, do you have your CPT selected in the “Select Post Type” list in your Query Loop Settings?

    Thread Starter yephy

    (@yephy)

    Thanks Reply.

    I created a custom post type myself using PHP code and had its own taxonomy. When I use QUERY LOOP to create a post loop about a category of this custom post type, I have already selected this custom post type in the POST TYPE, but further “SELECT QUERY PARAMETER” selects the taxonomy.

    Next, define TAXONOMIES as category, but you can only see the category list of the default post type in the drop-down list; you cannot see the category list of the custom article;

    Going one step up, if I try to look for the taxonomy for my custom post type in the “SELECT QUERY PARAMETER” list, there is none…

    Thread Starter yephy

    (@yephy)

    In addition, I also found a problem. When I created a new element and tried to replace the query list format of the website’s default search page, I set the ELEMENT TYPE to Loop Template, and set the “Position” to “Search Results”, and then added the For an H title, try to change its DYNAMIC TEXT TYPE to Title. When editing in the background, the default title of the search page is displayed, but when I return to the front-end search page to view it, this title will become the first in the search results. The title of this post…how to solve it?

    Thread Starter yephy

    (@yephy)

    Going back to the first question, I tried to find the backend file of the plug-in, which is: /generateblocks/src/components/taxonomies-select/index.js. In this file, the following code content appears. I don’t think it is effective for itself. Define the taxonomy of posts to filter:

    export default function TaxonomiesSelect( props ) {
    	const {
    		taxonomy,
    		label,
    		onChange,
    		value = [],
    		help,
    		placeholder,
    		filterName = 'generateblocks.editor.taxonomies-select',
    	} = props;
    
    	const [ loadValues, setLoadValues ] = useState( value.length > 0 );
    	const [ search, setSearch ] = useDebounceState( '', 500 );
    	const isSearchById = !! search.trim() && ! search.trim().match( /\D/g );
    	const includeSearchId = isSearchById ? [ search.replace( /\D/g, '' ) ] : undefined;
    	const { records, isLoading } = usePersistentTaxonomyRecords( taxonomy, {
    		per_page: !! search ? 100 : 10,
    		search: !! search && ! isSearchById ? search : undefined,
    		include: loadValues ? value : includeSearchId,
    	} );
    
    	useEffect( () => {
    		if ( loadValues && records.some( ( tax ) => ( value.includes( tax.id ) ) ) ) {
    			setLoadValues( false );
    		}
    	}, [ JSON.stringify( records ), JSON.stringify( value ) ] );
    
    	const taxonomiesOptions = useMemo( () => {
    		const filteredTaxonomies = records
    			.reduce( ( result, tax ) => {
    				result.push( { value: tax.id, label: '#' + tax.id + ': ' + tax.name } );
    				return result;
    			}, [] );
    
    		return applyFilters( filterName, filteredTaxonomies );
    	}, [ JSON.stringify( records ) ] );
    
    	const selectedValues = taxonomiesOptions.filter( ( option ) => ( value.includes( option.value ) ) );
    
    	return (
    		<AdvancedSelect
    			id={ 'gblocks-select-author' }
    			label={ label || __( 'Select terms', 'generateblocks' ) }
    			help={ help }
    			placeholder={ placeholder || __( 'Search authors…', 'generateblocks' ) }
    			options={ taxonomiesOptions }
    			isMulti
    			isSearchable
    			value={ selectedValues }
    			onChange={ onChange }
    			isLoading={ isLoading }
    			onInputChange={ ( inputValue, { action } ) => {
    				if ( 'input-change' === action ) {
    					setSearch( inputValue );
    				}
    			} }
    		/>
    	);
    }
    Plugin Support fernandoazarcon2

    (@fernandoazarcon2)

    I see. Is your custom taxonomy set to true for “Show in REST API”? If not, can you set it to true?

    Thread Starter yephy

    (@yephy)

    So talented, thank you very much!
    The first problem, the problem of custom article classification filtering has been perfectly solved!
    It was my mistake, I ignored the problem of Show in REST API!

    Second question, please take a look at the issue about the abnormal title display after the search page is replaced!

    Thread Starter yephy

    (@yephy)

    This search page title seems to be called because the element type is Loop Template, which causes any content on the page to be included in the loop results on the search page, so the title can only be displayed as a loop result. The title of the article is not the page title of the search page!

    Plugin Support David

    (@diggeddy)

    Hi there,

    the second question is related to ( i assume ) the GP Premium Elements module. To provide support for that you will need to raise a topic in the premium support forum, link below:

    https://generate.support

    Thread Starter yephy

    (@yephy)

    OK, Thanks

    • This reply was modified 1 year, 2 months ago by yephy.
    Plugin Support David

    (@diggeddy)

    You’re welcome

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘QUERY LOOP module does not support custom post types’ is closed to new replies.