WordPress Settings API error

I believe the underlying problem is that the option array keys don’t exist yet. Let’s start here, in your initialization function: if( false == get_option( ‘thanathos_theme_display_options’ ) ) { add_option( ‘thanathos_theme_display_options’ ); } First, this: false == get_option( ‘thanathos_theme_display_options’ ) …should be this: false === get_option( ‘thanathos_theme_display_options’ ) …because you’re expecting an array to be … Read more

How can I set image sizes and still have responsive images using the srcset attribute?

The srcset attribute is constructed from images that are the same aspect ratio. Create a few of those and you’ll be ok. add_image_size( ‘compare-offer-box’, 400, 300, true); add_image_size( ‘compare-offer-box-2’, 800, 600, true); add_image_size( ‘compare-offer-box-3’, 1200, 900, true); for example. The fourth, boolean, argument tells WP to crop to the exact proportions. To resize without cropping, … Read more

How to modify an image block in Gutenberg WordPress 5?

After some digging and trial/error I have came up with a couple solutions. I was looking for a “Gutenberg” solution so I could avoid using str_replace. First, we need to enqueue our JS and include the wp.blocks package // Add to functions.php function gutenberg_enqueue() { wp_enqueue_script( ‘myguten-script’, // get_template_directory_uri() . ‘/js/gutenberg.js’, // For Parent Themes … Read more

How to remove “prev, next, shortlink” from wp_head()?

One shouldn’t remove them. They are important for search engines like Google. One can remove them like this: remove_action(‘wp_head’, ‘wp_shortlink_wp_head’); remove_action(‘wp_head’, ‘adjacent_posts_rel_link_wp_head’); Here are some additional explanations why they should not be removed and how this effects search engines: Core Code insertion The related trac ticket Google Webmaster Central Article about changes & impact on … Read more

Change admin bar to default:off

add_action(“user_register”, “set_user_admin_bar_false_by_default”, 10, 1); function set_user_admin_bar_false_by_default($user_id) { update_user_meta( $user_id, ‘show_admin_bar_front’, ‘false’ ); update_user_meta( $user_id, ‘show_admin_bar_admin’, ‘false’ ); } Place in theme functions file or you can make into a plugin. Once user registers it will go and set the users admin bar prefs to false. The user can then, once logged in, set this to … Read more

What are the ADVANTAGES of ORIGINAL wordpress template structure?

First, as @Toscho implies, the get_header() and get_footer() template tags simply include files named header.php and footer.php, respectively. Both template tags are called from within template files, and you can separate content between template file (index.php) and template part file (header.php, footer.php) any way you want. So, WordPress certainly can accommodate your latter example. That … Read more

How to limit wordpress menu depth in admin panel

Follow up on @jmarceli’s and @squarecandy’s great answers. Here is a solution that allows for: Easier scaling (set an object in the php action) Updates to the correct menu depth when the location checkboxes are changed /** * Limit max menu depth in admin panel */ function limit_admin_menu_depth($hook) { if ($hook != ‘nav-menus.php’) return; wp_register_script(‘limit-admin-menu-depth’, … Read more

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