Forum Replies Created

Viewing 5 replies - 1 through 5 (of 5 total)
  • Forum: Fixing WordPress
    In reply to: URL’s
    Thread Starter nickc110

    (@nickc110)

    Hi Sage,

    Thank you for the reply.

    You solution works but when someone updates/changes the sub page content it is no longer that pages parent which would be problematic for the client.

    Thanks

    Thread Starter nickc110

    (@nickc110)

    so to get the proper values I need to unserialize?

    Thread Starter nickc110

    (@nickc110)

    Hi, Sorry for losing you. The data I get when doing var_dump(get_option(‘social_links) is:

    a:2:{s:17:”social_link_names”;N;s:16:”social_link_urls”;N;}

    Many Thanks

    Thread Starter nickc110

    (@nickc110)

    Hi, Thanks for your help. I am fairly new so I am sorry if I dont fully understand things. Its probably easier if I put my full options page code here:

    <?php
    
    function enqueue_options_page_scripts() {
        wp_enqueue_script('options-page-script', get_template_directory_uri().'/options-page/options.js', 'jquery');
        wp_enqueue_style('options-page-style', get_template_directory_uri().'/options-page/options-style.css');
        wp_enqueue_script('jquery-ui-tabs', 'jquery');
        wp_enqueue_script('jquery-ui-sortable', 'jquery');
    }
    add_action( 'admin_enqueue_scripts', 'enqueue_options_page_scripts' );
    
    add_action('admin_menu', 'create_options_menu_page');
    function create_options_menu_page() {
    	add_menu_page(
            'Website Options',
            'Options (DEV)',
            'administrator',
            'website-options-ct',
            'options_page_callback'
        );
    
    	add_action( 'admin_init', 'register_options_page_settings' );
    }
    
    function register_options_page_settings() {
    	register_setting( 'options-page-settings-group', 'social_links' );
    }
    
    function options_page_callback() {
        ?>
    
        <div class="wrap custom-options-page">
            <h1>Options</h1>
    
            <form method="post" action="options.php">
    
                <?php settings_fields( 'options-page-settings-group' ); ?>
                <?php do_settings_sections( 'options-page-settings-group'); ?>
    
                <div class="options-left-panel">
                    <div class="options-left-panel-inside">
    
                        <div id="option-nav-tabs" class="option-nav-tabs">
    
                            <ul class="nav-links">
                                <li><a href="#tab-one"><strong>Social Links</strong></a></li>
                            </ul>
    
                            <div class="clear"></div>
    
                            <div id="tab-one">
                                <input type="text" name="social_link_name[]" class="widefat">
                                <input type="url" name="social_link_url[]" class="widefat">
    
                                <input type="text" name="social_link_name[]" class="widefat">
                                <input type="url" name="social_link_url[]" class="widefat">
    
                                <input type="text" name="social_link_name[]" class="widefat">
                                <input type="url" name="social_link_url[]" class="widefat"> 
    
                                <?php
                                $array_of_options = array(
                                    'social_link_names' => $_POST['social_link_name[]'],
                                    'social_link_urls' => $_POST['social_link_url[]']
                                );
                                update_option( 'social_links', $array_of_options );
                                ?>
                            </div>
                        </div>
                    </div>
                </div>
    
                <div class="options-right-panel">
                    <div class="options-right-panel-inside">
                        <?php submit_button(); ?>
                    </div>
                </div>
    
            </form>
        </div>
    <?php }
    Thread Starter nickc110

    (@nickc110)

    I have been looking at this: https://developer.ww.wp.xz.cn/plugins/settings/individual-options-versus-arrays-of-options/ and if you look at the storing an array of options bit that is what I have tried but trying to get the values from the field using $_POST or $_GET is not working below id what I am currently using,

    All of this is in the form with action: options.php:

    <input type="text" name="social_link_name[]" class="widefat">
    <input type="url" name="social_link_url[]" class="widefat">
    
    <input type="text" name="social_link_name[]" class="widefat">
    <input type="url" name="social_link_url[]" class="widefat">
    
    <input type="text" name="social_link_name[]" class="widefat">
    <input type="url" name="social_link_url[]" class="widefat"> 
    
    <?php
    $array_of_options = array(
            'social_link_names' => $_POST['social_link_name[]'],
            'social_link_urls' => $_POST['social_link_url[]']
    );
    update_option( 'social_links', $array_of_options );
    ?>

    Thanks

Viewing 5 replies - 1 through 5 (of 5 total)