WordPress.org

Ready to get started?Download WordPress

Forums

Default Page Parent (9 posts)

  1. 8-Bit
    Member
    Posted 7 years ago #

    WP ver: 2.0.4

    What I'm talking about: In the Write Page section, the 'Page Parent' drop down box.

    What I'd like to do: When I goto create a new page the default 'place' the create the new page is "Main Page - no parent". I'd like to change that default setting so that the first option it chooses on that list is an actual page.

    Or (preferred)

    I'd like to restrict a user role to only be able to create pages with a single or small list of possible parents.

    If I can't do this or something that has a similar effect than I'm down to just trusting users not to create pages with no parents.

    Help needed! Thanks in advance! If you need more information please ask!

  2. 8-Bit
    Member
    Posted 7 years ago #

    It's been three days and I havn't figured out a solution yet (and yes, I've been working on it). Please help?

  3. moshu
    Member
    Posted 7 years ago #

    The most likely reason why your post went without a reply: it requires very specific coding knowledge - either as a plugin or modifying core files that few people have such level of familiarity with the code.
    Also, it might take more work than just a casual reply.

    Knowing that many helpers go first to the unanswered topics when they come online, I guess many of us just left the topic there (unanswered) until some knowledgeable good soul comes around. Now, that you successfully removed the topic from there - I could answer this, which is not of much help, I know.

  4. 8-Bit
    Member
    Posted 7 years ago #

    Moshu:

    Oops. Sorry about that. I feel like I've been some kind of annoyance now, y'know asking for help and all. (oh jeez, that sounded like an insult... it's not)

    Anyway, I figured out part of the solution I think.

    In file "edit-page-form.php", starting around line 67 the describer for the "Parent Page" drop down menu code is listed there and it looks like...

    <fieldset id="pageparent" class="dbx-box">
    <h3 class="dbx-handle"><?php _e('Page Parent') ?></h3>
    <div class="dbx-content"><select name="parent_id">
    <option value='0'><?php _e('Main Page (no parent)'); ?></option>
    <?php parent_dropdown($post->post_parent); ?>
    </select>
    </div>
    </fieldset>

    The key line here is:

    <option value='0'><?php _e('Main Page (no parent)');

    If you just change the option value to whatever page you want the example:

    If I wanted the page whose location is "http://website/wp/?page_id=666" you would change that line to read

    <option value='666'><?php _e('The Satan Page!');

    That last page is just the text that the drop down box lists as default.

    Now, this remove the ability to make new pages that have no parents. This isn't a problem in my case, I have a copy of the original code saved so I can just upload it elsewhere, password protect that page, and just go to whenever I want to make a parent-less page. Not something I really need to do and it's worth it for this quick fix.

    If you have a better solution please list it here, not just for me but also for anyone else who has a similar need. I'll update this if I think it's needed.

  5. Kafkaesqui

    Posted 7 years ago #

    Hmm.

    I'll look over this a bit and see if there's a way to set a default parent Page without needing to rewrite the WordPress core code.

  6. 8-Bit
    Member
    Posted 7 years ago #

    O.O! That'd be awesome Kafkaesqui, thanks a lot!

  7. moshu
    Member
    Posted 7 years ago #

    Oh, no need for apologies. It's natural you wanted help and, probably, thought your post went un-noticed. In my reply I tried to explain how the helpers work...
    The good news is the "knowledgeable good soul" showed up in the person of Kafkaesqui :)
    (he is a coder - I'm just a traffic director)

  8. Kafkaesqui

    Posted 7 years ago #

    Ok, here's a little plugin that accomplishes what you're after:

    Default Page Parent:
    Download plugin | View source

    The plugin has one user-configurable variable you should know about:

    $page_id = The ID # for the Page you want acting as the default Page Parent in the list.

    You can edit the variable through the Plugin Editor in WordPress, or in a text editor offline. This needs to be set before activating the plugin.

    Note: The plugin could be made even more elaborate by locking down Page Parent to one choice, exclude certain Pages, remove the Page Parent list all together and provide a hidden input that sets it automatically, hit on your request to manage through user roles, etc. But I didn't have all night to play. :)

  9. 8-Bit
    Member
    Posted 7 years ago #

    Incredible! That plug-in you made did the trick! Not only that, but it worked flawlessly.

    Looking over the code, I don't I see anything to exclude pages, ect. but I assume it's not supposed to be there. Those functions would incredibly useful to me, as they would do EXACTLY what I'm looking for.

    If it wouldn't be too much to ask, could you play some more tomorrow or sometime soon?

    I can't really thank you enough for doing this for me. Both of you, Moshu and Kafkaesqui.

    *skips off down the sidewalk, new plug-in code in hand*

Topic Closed

This topic has been closed to new replies.

About this Topic