Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

The theme I'm using provides an admin page that lets me easily setup jQuery sliders on my homepage, but it limits me to five. Now I'm able to go into the actual theme files and edit these so that the backend asks for 7 slides and the front end displays all 7. No problems there, I know exactly where and what to edit.

But... editing the theme is not advisable and child themes are the way to go. However, I can't figure out how to make these changes in the child theme, specifically the backend section that takes in the slide info.

I've attempted to use my child theme functions.php page to remove the original hooks that call the function building this part of the page. I was able to do that. In attempting to recreate that function with my changes and then hook it into the page I was unsuccessful.

I've attempted to simply overwrite the various pages using my child theme and that didn't work.

I've attempted to use the child themes functions.php page to flat out rewrite the function that builds this part of the page, and that didn't work either.

I tried a new functions.php in the admin folder of my child theme. Nothing. The original theme has an admin-functions.php page and I tried overwriting that in my child theme and got nothing.

This is really my first time using child themes so I don't have a ton of experience with them. It's also my first attempt and tweaking anything on the backend/admin side.

I know I'm supposed to ask for code specific help but I don't even know which of my tactics above is most likely to be successful because I've never done anything like this. Tell me which potential solution to focus on and I'll be happy to supply code in that regard.

Thanks in advance.

Edit:
in the theme files I can edit this function in the admin/settings.php page of my theme to change the number of slides.

function cryout_setting_frontslider2_fn() {
global $parabolas;

 $items = array("Custom Slides", "Latest Posts", "Random Posts", "Sticky Posts", "Latest Posts from Category" , "Random Posts from Category", "Specific Posts");
$itemsare = array( __("Custom Slides","parabola"), __("Latest Posts","parabola"), __("Random Posts","parabola"),__("Sticky Posts","parabola"), __("Latest Posts from Category","parabola"), __("Random Posts from Category","parabola"), __("Specific Posts","parabola"));
echo "<strong> Slides content: </strong> ";
echo "<select id='parabola_slideType' name='parabola_settings[parabola_slideType]'>";
foreach($items as $id=>$item) {
    echo "<option value='$item'";
    selected($parabolas['parabola_slideType'],$item);
    echo ">$itemsare[$id]</option>";
}
echo "</select>";
echo "<div><small>".__("Only the slides with a defined image will become active and visible in the live slider.<br>When using slides from posts, make sure the selected posts have featured images.<br>Read the FAQs for more info.","parabola")."</small></div>";
 ?>

 <div class="underSelector">
      <div id="sliderLatestPosts" class="slideDivs">
           <span><?php _e('Latest posts will be loaded into the slider.','parabola'); ?> </span>
      </div>

      <div id="sliderRandomPosts" class="slideDivs">
           <span><?php _e('Random posts will be loaded into the slider.','parabola'); ?> </span>
      </div>

      <div id="sliderLatestCateg" class="slideDivs">
           <span><?php _e('Latest posts from the category you choose will be loaded in the slider.','parabola'); ?> </span>
      </div>

      <div id="sliderRandomCateg" class="slideDivs">
           <span><?php _e('Random posts from the category you choose will be loaded into the slider.','parabola'); ?> </span>
      </div>

      <div id="sliderStickyPosts" class="slideDivs">
           <span><?php _e('Only sticky posts will be loaded into the slider.','parabola'); ?> </span>
      </div>

      <div id="sliderSpecificPosts" class="slideDivs">
           <span><?php _e('List the post IDs you want to display (separated by a comma): ','parabola'); ?> </span>
           <input id='parabola_slideSpecific' name='parabola_settings[parabola_slideSpecific]' size='44' type='text' value='<?php echo esc_attr( $parabolas['parabola_slideSpecific'] ) ?>' />
      </div>

      <div id="slider-category">
           <span><?php _e('<br> Choose the category: ','parabola'); ?> </span>
           <select id="parabola_slideCateg" name='parabola_settings[parabola_slideCateg]'>
           <option value=""><?php echo esc_attr(__('Select Category','parabola')); ?></option>
           <?php echo $parabolas["parabola_slideCateg"];
           $categories = get_categories();
           foreach ($categories as $category) {
                $option = '<option value="'.$category->category_nicename.'" ';
            $option .= selected($parabolas["parabola_slideCateg"], $category->category_nicename, false).' >';
            $option .= $category->cat_name;
            $option .= ' ('.$category->category_count.')';
            $option .= '</option>';
            echo $option;
           } ?>
           </select>
      </div>

      <span id="slider-post-number"><?php _e('Number of posts to show:','parabola'); ?>
           <input id='parabola_slideNumber' name='parabola_settings[parabola_slideNumber]' size='3' type='text' value='<?php echo esc_attr( $parabolas['parabola_slideNumber'] ) ?>' />
      </span>

      <div id="sliderCustomSlides" class="slideDivs">

      <?php
      // CHANGE THE '5' BELOW TO '7' FOR 7 SLIDES
      for ($i=1;$i<=5;$i++):
      // let's generate the slides
      ?>
           <div class="slidebox">
           <h4 class="slidetitle" ><?php _e("Slide","parabola");?> <?php echo $i; ?></h4>
           <div class="slidercontent">
                <h5><?php _e("Image","parabola");?></h5>
                <input type="text" value="<?php echo esc_url($parabolas['parabola_sliderimg'.$i]); ?>" name="parabola_settings[parabola_sliderimg<?php echo $i; ?>]"
                     id="parabola_sliderimg<?php echo $i; ?>" class="slideimages" />
                <span class="description"><a href="#" class="upload_image_button button"><?php _e( 'Select / Upload Image', 'parabola' );?></a> </span>
                <h5> <?php _e("Title","parabola");?> </h5>
                <input id='parabola_slidertitle<?php echo $i; ?>' name='parabola_settings[parabola_slidertitle<?php echo $i; ?>]' size='50' type='text'
                     value='<?php echo esc_attr( $parabolas['parabola_slidertitle'.$i] ) ?>' />
                <h5> <?php _e("Text","parabola");?> </h5>
                <textarea id='parabola_slidertext<?php echo $i; ?>' name='parabola_settings[parabola_slidertext<?php echo $i; ?>]' rows='3' cols='50'
                     type='textarea'><?php echo esc_attr($parabolas['parabola_slidertext'.$i]) ?></textarea>
                <h5> <?php _e("Link","parabola");?> </h5>
                <input id='parabola_sliderlink<?php echo $i; ?>' name='parabola_settings[parabola_sliderlink<?php echo $i; ?>]' size='50' type='text'
                     value='<?php echo esc_url( $parabolas['parabola_sliderlink'.$i] ) ?>' />
           </div>
           </div>

      <?php endfor; ?>
      </div> <!-- customSlides -->
 </div>

this above function is called in admin/main.php of the theme

function parabola_init_fn(){
register_setting('parabola_settings', 'parabola_settings', 'parabola_settings_validate');

...

add_settings_field('parabola_frontslider2', __('Slides','parabola') , 'cryout_setting_frontslider2_fn', __FILE__, 'presentation_section');
}

the parabola_init_fn function is called higher up on that same page

add_action('admin_init', 'parabola_init_fn' );

as I said before, I was able to add the following to my child theme functions.php

add_action('init','unhook_parabola_init_fn');
add_action('admin_init', 'parabola_init_fn_new' );

function unhook_parabola_init_fn() {
    remove_action('admin_init','parabola_init_fn');
}

this would remove the original sections of the backend page that let me customize the theme but would not load the parabola_init_fn_new function that was exactly the same as the parabola_init_fn function except for the call to cryout_setting_frontslider2_fn_new, which contained my edit to get more slider options in the backend, instead of the original cryout_setting_frontslider2_fn.

I hope that all makes sense, but I doubt it will.

2nd Edit: In the functions.php of my child theme I tried to break things down a bit to see where the problem was occuring.

First I changed my hooks so that instead of just unhooking the one function I was also rehooking it.

add_action('init','unhook_parabola_init_fn');
add_action('admin_init','parabola_init_fn');

function unhook_parabola_init_fn() {
    remove_action('admin_init','parabola_init_fn');
}

My thinking was that this would go get the function and the page would load fine and proper, but that's not what happened. The page doesn't load anything, all white screen. So something went wrong, maybe I need to have parabola_init_fn in the functions.php so I tried that.

Nothing. Same blank page.

Finally, when I change the second hook to parabola_init_fn_new is when the page loads at all. The editable section of my page is still gone.

I have no idea what's happening.

3rd Edit: Figured it out.

There was another function calling parabola_init_fn. I had to add a bunch more stuff to my functions.php page in order to make sure this was pointing in the right place, but it's now working.

Thanks for all your help guys.

share|improve this question
1  
Can you please add some code. It is difficult to answer your question properly without anything concrete. Also post what you have so far. –  Pieter Goosen Mar 12 at 17:10
    
What you did should work. I would guess that there is Javascript that isn't being loaded correctly due to your change. –  s_ha_dum Mar 12 at 19:53

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.