Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Merv Barrett

    (@mervb1)

    As this is a WordPress custom post type then you need to use the same slug as far as I am aware. But instead of using the /commercial/ slug just create a page and use a shortcode, eg call the page:

    Commercial For Lease (slug would be) /commercial-for-lease/

    Shortcode to use is the [listing_category] Shortcode.

    [listing_category commercial_listing_type=lease status=current]

    Thread Starter bluantinoo

    (@bluantinoo)

    Ok, understood the workaround.

    But, let me point out that in WP you can have different slugs for archive and for single.

    In register_post_type args you can specify both:

    'rewrite' = array(
        'slug' => 'property',
        'with_front' => false,
        'pages' => true,
        'feeds' => false,
    ),
    'has_archive' => 'properties',

    the “slug” in rewrite array is the slug of single posts

    the string in “has_archive” is the slug of the archive

    Plugin Author Merv Barrett

    (@mervb1)

    Ah in that case you can use the epl_property_post_type_args filter to alter the defaults.

    And i did not know that so thanks. I thought it was a true/false value but its also a string… ??

    WordPress register_post_type()

    The EPL_PROPERTY_DISABLE_ARCHIVE constant will let you change that value

    (as we thought it was true/false the constant name could be better bout you can still use it:

    How to modify the custom post type slugs for each listing type for localisation or other names

    define( EPL_PROPERTY_DISABLE_ARCHIVE, 'my-new-slug' );
    Plugin Author Merv Barrett

    (@mervb1)

    hmmm, doesn’t seem to work…? Ah our code is only supporting true/false

    Our code is written like this. Will add this as a feature request

    $archives = defined( 'EPL_PROPERTY_DISABLE_ARCHIVE' ) && EPL_PROPERTY_DISABLE_ARCHIVE ? false : true;

    GitIssue: https://github.com/easypropertylistings/Easy-Property-Listings/issues/1053

    What you can do in the meantime is use the filter epl_property_post_type_args

    You can replace the has_archive using that filter e.g.

    function my_epl_property_post_type_args( $array ) {
    	
    	$array['has_archive'] = 'properties';
    	
    	return $array;
    	
    }
    add_filter( 'epl_property_post_type_args', 'my_epl_property_post_type_args' );

    And this solution makes the feature request redundant

    • This reply was modified 1 year, 8 months ago by Merv Barrett.
    • This reply was modified 1 year, 8 months ago by Merv Barrett.
    Thread Starter bluantinoo

    (@bluantinoo)

    Yes, actually I’ve already been doing with the epl_property_post_type_args filter, for the very reason you pointed out.

    But I don’t think the feature request is redundant, defining the constant would be easier for most users.

    thanks anyway for the quick support!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Different Slug for archive and single property’ is closed to new replies.