Custom Background by Page IDs

The CSS is generated on the file inc/custom-css.php, the background color is set on line 76: $background = sanitize_hex_color_no_hash( get_theme_mod( ‘background_color’ ) ); So you can take advantage of the theme_mod_{$name} filter, which changes the value of the get_theme_mod($name) function, by adding this to your functions.php file: add_filter( ‘theme_mod_background_color’, function( $value ) { $custom_bg_page_ids = … Read more

Which is the correct way to conditionally enqueue a CSS file?

I agreed with @PatJ — you should check if get_queried_object() returns an object or not. But you could simplify your code by simply using is_category() and in_category() which are conditional tags in WordPress: if ( is_category( 3 ) || in_category( ‘arta’ ) ) { wp_enqueue_style( ‘twentytwenty-style-2’, get_stylesheet_directory_uri() . ‘/style-arta.css’, array(), $theme_version ); }

Not connecting to database in file with multiple MySQL connections

When you include wp-load.php, WordPress will load wp-config.php, where constants with the same identifiers you have chosen here are already defined. This should be throwing warnings regarding the duplicate definition. Because you cannot re-define constants, the values you are attempting to set in this file are ignored. Choose different names for them if they are … Read more

WordPress admin-ajax.php 400 bad request

Your full form code does contain a hidden input named action with the value send_form. However, you’re not sending it correctly, because of the the contentType part in your JS script, which submits the form data as a JSON payload, but note that the old admin-ajax.php endpoint doesn’t support JSON payload, hence $_REQUEST[‘action’] would be … Read more

Does wordpress templates always in files or in database?

But there is no content directory in template directory. Actually, with the following: get_template_part( ‘templates/content’, ‘header-private’ ); get_template_part( ‘templates/content’, ‘header-public’ ); WordPress will search in the templates folder for content-header-private.php or content-header-public.php, and if found, it is loaded. Else, WordPress will attempt to load the content.php file instead. So WordPress (or get_template_part()) will not search … Read more

Make PHP work with HTML tags

From your code the proper structure would be if ( is_singular() ) { if (get_post_meta(get_the_ID(), ‘square_image’, true)) { echo ‘<img src=”‘ . get_post_meta($post->ID, ‘square_image’, true) . ‘”/>’; } else { the_post_thumbnail( ‘thumbnail’ ); } } We can make it a bit better by creating a variable that will contain the meta data so we don’t … Read more

Custom plugin settings link doesn’t append current class to menu item when visited? Why?

I noticed your apwb_settings_page() function is adding the “Postal Pricing Settings” submenu using add_options_page(), and the documentation stated that: (bold formatting added by me) This function is a simple wrapper for a call to add_submenu_page(), passing the received arguments and specifying ‘options-general.php‘ as the $parent_slug argument. This means the new options page will be added … Read more

Theme requires allow_url_include = on in php.ini

Okay, first off, that’s an incredibly badly made theme. Your item number 2 there indicates to me that he making AJAX calls in entirely the wrong way. Secondly, look for anything in the theme that is using http but not in a link. allow_url_include basically lets you include some PHP from a remote site, which … Read more

Building a WordPress App

I’m curious how/where you got the impression that desktop apps are more secure than the WP admin. For better security, you can enable SSL for the normal WP admin web interface, by adding this line to wp-config.php: define(‘FORCE_SSL_ADMIN’, true); More info here: http://codex.wordpress.org/Administration_Over_SSL

Shortcode returns values in the wrong order

it is b/c wp_list_pages ECHOES by default. so it echoes before your return happens. wherever you are defining your $args, set ‘echo’ => FALSE, see http://codex.wordpress.org/Function_Reference/wp_list_pages