• I have made a rewrite code and am getting a redirect loop:

    add_action( ‘init’, ‘wpse16902_init’ );
    function wpse16902_init() {
    $GLOBALS[‘wp_rewrite’]->use_verbose_page_rules = true;
    }

    add_filter( ‘page_rewrite_rules’, ‘wpse16902_collect_page_rewrite_rules’ );
    function wpse16902_collect_page_rewrite_rules( $page_rewrite_rules )
    {
    $GLOBALS[‘wpse16902_page_rewrite_rules’] = $page_rewrite_rules;
    return array();
    }

    add_filter( ‘rewrite_rules_array’, ‘wspe16902_prepend_page_rewrite_rules’ );
    function wspe16902_prepend_page_rewrite_rules( $rewrite_rules )
    {
    return $GLOBALS[‘wpse16902_page_rewrite_rules’] + $rewrite_rules;
    }

    function wpse_56769_post_link( $permalink, $post ) {

    $terms = wp_get_post_terms( $post->ID, ‘resource_type’ );
    if ( ! empty( $terms ) && ! is_wp_error( $terms ) ) {
    $thisTerm = current( $terms )->slug;
    $permalink = str_replace( ‘%resource_type%’, $thisTerm, $permalink );
    }

    $iterms = wp_get_post_terms( $post->ID, ‘item_type’ );
    if ( ! empty( $iterms ) && ! is_wp_error( $iterms ) ) {
    $thisTerm = current( $iterms )->slug;
    $permalink = str_replace( ‘%item_type%’, $thisTerm, $permalink );
    }

    $jrterms = wp_get_post_terms( $post->ID, ‘jnyc_resource_type’ );
    if ( ! empty( $jrterms ) && ! is_wp_error( $jrterms ) ) {
    $thisTerm = current( $jrterms )->slug;
    $thisTerm = ‘jugglenyc/’ . $thisTerm; //this is the domain mapping part
    $permalink = str_replace( ‘%jnyc_resource_type%’, $thisTerm, $permalink );
    }

    // if(get_field( ‘permalink’, $post->ID )){
    // $thisPerma = get_field( ‘permalink’, $post->ID );
    // $thisPerma = ‘jugglenyc/’ . $thisPerma;
    // $permalink = str_replace( ‘%perma%’, $thisPerma, $permalink );
    // }

    return $permalink;

    }
    add_filter( ‘post_type_link’, ‘wpse_56769_post_link’, 10, 2 );

    function wpse_56769_rewrite_verbose_page_rules( $pass_through = NULL ) {

    $permastruct = $GLOBALS[ ‘wp_rewrite’ ]->permalink_structure;
    $permastruct = trim( $permastruct, ‘/%’ );
    if ( 0 !== strpos( $permastruct, ‘resource_type%’ ) || 0 !== strpos( $permastruct, ‘item_type%’ )) {
    return $pass_through;
    }

    $GLOBALS[ ‘wp_rewrite’ ]->use_verbose_page_rules = TRUE;
    return $pass_through;
    }
    add_filter( ‘page_rewrite_rules’, ‘wpse_56769_rewrite_verbose_page_rules’, PHP_INT_MAX );
    add_filter( ‘do_parse_request’, ‘wpse_56769_rewrite_verbose_page_rules’, PHP_INT_MAX );

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Plugin Author matthias.wagner

    (@matthiaswagner)

    @unaomnia, sorry for the late response 😉

    i’m afraid we really can not give support for your custom code. of course feel free to use the forum to discuss things with other users, but we will only be here for problems with the core functionality…

    good luck,
    matt

Viewing 1 replies (of 1 total)
  • The topic ‘Redirect Loop’ is closed to new replies.