Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1397507

    Hi,
    is there any possibility to disable or hide the automatically generated portfolio archive page (…/portfolio_entries/) within Enfold or do you know another solution?
    Regards, Stefan

    #1397526

    Hi Stefan,

    Please add this code in your child theme’s functions.php file(at the bottom):

    add_action('init', 'avia_deregister_portfolio', 5);
    function avia_deregister_portfolio()
    {
    	remove_action('init', 'portfolio_register');  
    }

    If you aren’t using a child theme yet, you can download and find instructions on how to use it here: https://kriesi.at/documentation/enfold/child-theme/ (make sure to import parent theme options).

    Best regards,
    Nikko

    #1397538

    Hi Nikko,

    thanks for your reply but this code completely disables the portfolio functionality on the website, right?
    I want to show portfolio entries on certain pages but the NOT on the automatically generated portfolio archive page (…/portfolio_entries/). An alternative would be to have password protection of this portfolio archive page.
    Any ideas?

    Regards,
    Stefan

    #1397574

    Hi Stefan,

    Are you referring to website.com/portfolio_entries? or website.com/portfolio_entries/category_name? the former returns 404 however the latter is not possible to remove, you can only change the slug in the URL so if there’s URL conflict it can be avoided. Removing archive pages of the custom post type is possible but not with custom taxonomy.

    Maybe you can try to play with it by re-registering the portfolio and just changing the values as you see fit.
    The one you need to change is $tax_args

    function register_portfolio()
    {
    	global $avia_config;
    
    	$labels = array(
    				'name'				=> _x( 'Portfolio Items', 'post type general name','avia_framework' ),
    				'singular_name'		=> _x( 'Portfolio Entry', 'post type singular name','avia_framework' ),
    				'add_new'			=> _x( 'Add New', 'portfolio', 'avia_framework' ),
    				'add_new_item'		=> __( 'Add New Portfolio Entry', 'avia_framework' ),
    				'edit_item'			=> __( 'Edit Portfolio Entry', 'avia_framework' ),
    				'new_item'			=> __( 'New Portfolio Entry', 'avia_framework' ),
    				'view_item'			=> __( 'View Portfolio Entry', 'avia_framework' ),
    				'search_items'		=> __( 'Search Portfolio Entries', 'avia_framework' ),
    				'not_found'			=>  __( 'No Portfolio Entries found', 'avia_framework' ),
    				'not_found_in_trash' => __( 'No Portfolio Entries found in Trash', 'avia_framework' ),
    				'parent_item_colon'	=> ''
    			);
    
    	$permalinks = get_option( 'avia_permalink_settings' );
    	if( ! is_array( $permalinks ) )
    	{
    		$permalinks = array();
    	}
    
    	$permalinks['portfolio_permalink_base'] = empty( $permalinks['portfolio_permalink_base'] ) ? __( 'portfolio-item', 'avia_framework' ) : $permalinks['portfolio_permalink_base'];
    	$permalinks['portfolio_entries_taxonomy_base'] = empty( $permalinks['portfolio_entries_taxonomy_base'] ) ? __( 'portfolio_entries', 'avia_framework' ) : $permalinks['portfolio_entries_taxonomy_base'];
    
    	$args = array(
    				'labels'			=> $labels,
    				'public'			=> true,
    				'show_ui'			=> true,
    				'capability_type'	=> 'post',
    				'hierarchical'		=> false,
    				'rewrite'			=> array(
    											'slug'			=> _x( $permalinks['portfolio_permalink_base'], 'URL slug', 'avia_framework' ),
    											'with_front'	=> true
    											),
    				'query_var'			=> true,
    				'show_in_nav_menus'	=> true,
    				'show_in_rest'		=> true,				//	set to false to disallow block editor
    				'taxonomies'		=> array( 'post_tag' ),
    				'supports'			=> array( 'title', 'thumbnail', 'excerpt', 'editor', 'comments', 'revisions' ),
    				'menu_icon'			=> 'dashicons-images-alt2'
    			);
    
    	$args = apply_filters( 'avf_portfolio_cpt_args', $args );
    	$avia_config['custom_post']['portfolio']['args'] = $args;
    
    	register_post_type( 'portfolio' , $args );
    
    
    	$tax_args = array(
    					'hierarchical'		=> true,
    					'label'				=> __( 'Portfolio Categories', 'avia_framework' ),
    					'singular_label'	=> __( 'Portfolio Category', 'avia_framework' ),
    					'rewrite'			=> array(
    												'slug'			=> _x( $permalinks['portfolio_entries_taxonomy_base'], 'URL slug', 'avia_framework' ),
    												'with_front'	=> true
    											),
    					'query_var'			=> true,
    					'show_in_rest'		=> true			//	set to false to disallow block editor
    				);
    
    	$avia_config['custom_taxonomy']['portfolio']['portfolio_entries']['args'] = $tax_args;
    
    	register_taxonomy( 'portfolio_entries', array( 'portfolio' ), $tax_args );
    
    	//deactivate the avia_flush_rewrites() function - not required because we rely on the default wordpress permalink settings
    	remove_action( 'wp_loaded', 'avia_flush_rewrites' );
    }
    
    add_action( 'init', 'register_portfolio' );

    You can see further information in WordPress Codes: https://developer.wordpress.org/reference/functions/register_taxonomy/

    Best regards,
    Nikko

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.