Flush rewrite rules on option update with Settings API

I register custom post type on init action and the validate which I’m writing about is set to register_setting inside admin_init action. This is the key to your issue. You’re registering the custom post type, and presumably you’re setting up the rewrite rules in that registration. When you call flush_rewrite_rules(), the rules are rebuilt right … Read more

Different Front page for Mobile

Switching the actual template file could work in the same way as above using get_template_part(). For example… <?php if ( wp_is_mobile() ) { // If it is a mobile device get_template_part( ‘mobile-front’, ‘page’ ); } else { // If it is not a mobile device get_template_part( ‘desktop-front’, ‘page’ ); } // end wp_is_mobile() To take … Read more

Change options table prefix only

This is actually not that hard, but you will have to excuse me for keeping it high level because this is just a stupid thing to do as all things which are security by obscurity. All you need to do is write your WPDB driver, which inherits the WPDB class. Place it in /wp-content/db.php file … Read more

Problem with Settings API: changes are not saved after submit

You need to register the proper settings fields in your PPAdminOptions() and also point the form action to options.php: function PPAdminOptions() { if ( !current_user_can( ‘manage_options’ ) ) { wp_die( __( ‘You do not have sufficient permissions to access this page.’ ) ); } ?> <div class=”wrap”> <h1><?php echo get_admin_page_title(); ?></h1> <form method=”post” action=”options.php”> <?php … Read more

get_theme_mod only returns false

The debugger tells me that get_theme_mod() is returning ‘false’, when I expect it to return the value of the selected item. get_theme_mod() isn’t working because when you registered the setting, you set the type to option: $wp_customize->add_setting(‘title_font’, array( ‘default’ => ‘Roboto Slab’, ‘capability’ => ‘edit_theme_options’, ‘type’ => ‘option’, ‘transport’ => ‘postMessage’ )); The possible values … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)