Viewing 15 replies - 1 through 15 (of 18 total)
  • @xhal44,

    Try a different theme, does the same thing happen?

    Thread Starter xhal44

    (@xhal44)

    Yes same thing happens on the default themes.

    @xhal44,

    When you say your home page isn’t a bog page – what is it then? and how are you achieving that?

    Thread Starter xhal44

    (@xhal44)

    WordPress admin > Settings > Reading

    I have my Front Page set to a custom page, and my Posts Page set to my blog page.

    When I’m on my front page, and subscribe, the page switches to the posts page, even though the URL remains the same (what it should be for my custom Front Page, which is basically just a static page).

    @xhal44,

    In the Appearance->Widgets page, open up the Subscribe2 widget. In the settings there, where it says “Post form content to page:” what option have you got selected?

    Thread Starter xhal44

    (@xhal44)

    I’m not using the widget, I’m using the following code in my footer:

    <?
    	$content = apply_filters('the_content', '<p><!--subscribe2--></p>');
    	echo $content;
    ?>

    However, tried the widget too, it was set on “Use Subscribe2 Default” and it’s doing the same thing. If I set it to a specific page, then it always redirects to that page, but if I set it to ‘Home’, then it does the content switch to the blog posts.

    @xhal44,

    That’s pretty import, thanks for mentioning it. Shame you didn’t advise that in the beginning.

    If you use the old ‘token’ like that is will always try to use the default Subscribe2 page. Try using the widget again and choose to use the Referring page.

    Sadly though I think this is to do with the way the default WordPress post query is handled and untiI can figure out the chain of events and how WordPress handles a static front page I can’t suggest a fix.

    Thread Starter xhal44

    (@xhal44)

    Unfortunately it still seems to be doing the content switch even with Use Referring Page. ??

    I think I might just change it to post to my Blog page.

    @xhal44,

    If you start using the shortcode or the widget I have a fix.

    In the classes/class-s2-frontend.php file, find the ‘shortcode’ function.

    Find the comment line that says this:
    // allow remote setting of email in form
    (Currently this is line 91 in version 10.15)

    Immediately before that comment and block of code add this new code:

    // Correct for Static front page redirect behaviour
    if ( 'page' == get_option( 'show_on_front' ) && is_front_page() ) {
    	$action = ' action="' . get_option( 'home' ) . '/?page_id=' . get_option( 'page_on_front') . '"';
    }

    Hopefully this code snippet will get committed by the new plugin developers.

    Thread Starter xhal44

    (@xhal44)

    Thanks! That did the trick. It’s a shame it has to specifically point to the page id, making the url a little unsightly.

    But I really appreciate you taking the time to come up with a fix, thanks again!

    @xhal44,

    I’ve actually come up with a slightly cleaner and more aesthetic code.

    Take the above block out again and change the block above where you inserted that to this:

    // if ID is provided, get permalink
    $action = '';
    if ( is_numeric( $args['id'] ) ) {
    	$action = ' action="' . get_permalink( $args['id'] ) . '"';
    } elseif ( 'home' === $args['id'] ) {
    	$action = ' action="' . get_site_url() . '"';
    } elseif ( 'self' === $args['id'] ) {
    	// Correct for Static front page redirect behaviour
    	if ( 'page' == get_option( 'show_on_front' ) && is_front_page() ) {
    		$post = get_post( get_option( 'page_on_front' ) );
    		$action = ' action="' . get_option( 'home' ) . '/' . $post->post_name . '/"';
    	} else {
    		$action = '';
    	}
    } elseif ( $this->subscribe2_options['s2page'] > 0 ) {
    	$action = ' action="' . get_permalink( $this->subscribe2_options['s2page'] ) . '"';
    }

    It ensures the submit page is only changed when it needs to be and also uses a prettier link.

    Thread Starter xhal44

    (@xhal44)

    This doesn’t seem to work. I replaced this:

    // if ID is provided, get permalink
    $action = '';
    if ( is_numeric($args['id']) ) {
    	$action = " action=\"" . get_permalink( $args['id'] ) . "\"";
    } elseif ( 'home' === $args['id'] ) {
    	$action = " action=\"" . get_site_url() . "\"";
    } elseif ( 'self' === $args['id'] ) {
    	$action = '';
    } elseif ( $this->subscribe2_options['s2page'] > 0 ) {
    	$action = " action=\"" . get_permalink( $this->subscribe2_options['s2page'] ) . "\"";
    }

    With your above code, and it was redirecting to the blog again.

    @xhal44,

    Strange, it worked on my testing. Are you using the Widget now? What setting do you have for the redirect?

    Thread Starter xhal44

    (@xhal44)

    I’m just using the shortcode now, [subscribe2]

    @xhal44,

    You need to use [subscribe2 id='self'].

Viewing 15 replies - 1 through 15 (of 18 total)
  • The topic ‘When I subscribe, front page changes to blog posts’ is closed to new replies.