• Resolved boborg

    (@boborg)


    I have the code below in my theme functions file. It seems both post types gets the the same title set in functions (whichever that comes first, the second is ignored). It seems post_type_archive thinks they are the same because both starts with tv- ? Any workaround other than renaming posttype removing the dash?

    elseif (is_post_type_archive(tv-pakker)) { ?>
    							<h1 class="archive-title">
    <?php 
    $titles = get_option( 'wpseo_titles' );
    $title  = $titles['title-ptarchive-tv-pakker'];
    
    echo apply_filters( 'the_title', $title );
    ?>
    </h1>
    							
    <?php } elseif (is_post_type_archive(tv-streaming)) { ?>
    							<h1 class="archive-title">
    <?php 
    $titles = get_option( 'wpseo_titles' );
    $title  = $titles['title-ptarchive-tv-streaming'];
    
    echo apply_filters( 'the_title', $title );
    ?>
    </h1>
    
    • This topic was modified 7 years, 6 months ago by boborg.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter boborg

    (@boborg)

    Code is in archive template not in functions file as I stated in my first post.

    • This reply was modified 7 years, 6 months ago by boborg.

    You’re missing quotes:
    is_post_type_archive(tv-streaming) needs to be is_post_type_archive('tv-streaming').

    It wouldn’t work without the dash either, because is_post_type_archive() needs a String of the post type name.

    If you used is_post_type_archive(tvstreaming) or something similar it would fail because is_post_type_archive() would be checking the value of the tvstreaming Constant, which won’t exist.

    Thread Starter boborg

    (@boborg)

    ok many thanks

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘is_post_type_archive gets confused with dash?’ is closed to new replies.