WordPress.org

Ready to get started?Download WordPress

Ideas

Prevent front page and posts page being set to the same page

  1. Mark / t31os
    Member

    12345

    Under Settings > Reading the user is given the option to set a front page and also a posts page, since these are independant features and have never been intended to share a single page (as outlined in the codex - ie. should never be set to the same page), could we include some simple jQuery to prevent the two dropdowns being set to the same values.

    add_action( 'admin_head-options-reading.php' , 'postspage_frontpage_not_same' );
    function postspage_frontpage_not_same() {
    	?>
    	<script type="text/javascript">
    	//<![CDATA[
    	jQuery(document).ready(function($) {
    
    		// Get the current selected values
    		var wp_frontpage = $('#page_on_front option:selected').val();
    		var wp_postspage = $('#page_for_posts option:selected').val();
    		if( wp_postspage != '' ) {
    			$('#page_on_front').find('option[value=' + wp_postspage + ']').attr("disabled","disabled");
    		}
    		if( wp_frontpage != '' ) {
    			$('#page_for_posts').find('option[value=' + wp_frontpage + ']').attr("disabled","disabled");
    		}
    		// Attach a change function to the front page dropdown
    		$('#page_on_front').change(function() {
    				// Re-declare the variable for use inside the scope of the function
    				var wp_frontpage = $('#page_on_front option:selected').val();
    				if( wp_frontpage != '' ) {
    					// Find a matching option in posts page dropdown
    					$('#page_for_posts').find('option[value=' + wp_frontpage + ']').attr("disabled","disabled");
    				}
    				$('#page_for_posts').find('option[value!=' + wp_frontpage + ']:disabled').removeAttr('disabled');
    		});
    		// Attach a change function to the posts page dropdown
    		$('#page_for_posts').change(function() {
    				// Re-declare the variable for use inside the scope of the function
    				var wp_postspage = $('#page_for_posts option:selected').val();
    				if( wp_postspage != '' ) {
    					// Find a matching option in the front page dropdown
    					$('#page_on_front').find('option[value=' + wp_postspage + ']').attr("disabled","disabled");
    				}
    				$('#page_on_front').find('option[value!=' + wp_postspage + ']:disabled').removeAttr('disabled');
    		});
    	});
    	//]]>
    	</script>
    	<?php
    }

    The method above is perhaps a little hacky, but i'll happily provide a proper patch if the idea is supported, i'm posting a working sample here in the hope users will take the code and test it.

    Let me know what you think.. :)

    Posted: 4 years ago #
  2. Jen Mylo
    Key Master

    We were just talking about the front page/posts page on Trac last night; what perfect timing! I'd love for you to submit a patch. You could use this ticket: http://core.trac.wordpress.org/ticket/12266

    Posted: 4 years ago #
  3. Mark / t31os
    Member

    12345

    Although the ticket is related, it seems to be addressing a perhaps seperate issue, are you sure the ticket above would be a suitable place to raise discussion for non-duplicative selection of the front/posts page settings?

    Side note: I've been taking little peeks at the ideas section over the last few days. It does appear to get very little use, are you aware of any efforts to raise awareness of using the Ideas section? Are members even aware they can use their forum login? I bring this up simply because i see alot of ideas receiving so little votes(when compared to the number of users registered).

    I realise the above is probably outside the scope of the discussion that should take place on an idea page, so feel free to trim the above and this paragraph out.

    Posted: 4 years ago #
  4. Ihor Vorotnov
    Member

    Mark, I'm afraid more than 90% of people using WordPress to power their websites are not aware of the Ideas section. I think it would be good to add some call-to-action button in WordPress Admin and on WordPress.org main page saying smth like "Help us make WP even better! Share your ideas and vote for the best ones to bring them to life". But, of course, it can result in lots of 'non-idea' requests from beginners who will ask for smth that is already available but they just don't know how to use it.

    BTW, I'm developing some premium themes and recently started to work on a separate section of my support website which has the same purpose. I call it 'Suggest a feature'. People can request some features for the themes they've got and vote on that feature request. Most voted features are added on next theme release offering customers a functional upgrade.

    Posted: 2 years ago #

RSS feed for this topic

Reply

You must log in to post.

  • Rating

    12345
    5 Votes
  • Status

    Good idea! We're working on it