How Can I Register Menus and Widgets Conditionally Based on Theme Options/Settings?

Below is the code you need. Your issue could be that you’re not first setting up the variable $display_options to contain your options, or that you not asking if the option is set. add_action(‘widgets_init’, ‘arphabet_widgets_init’); function arphabet_widgets_init() { $options = get_option(‘muffin_options’); if(isset($display_options[‘header_layout’]) && $display_options[‘header_layout’] == ‘1’) { register_widget(‘arphabet_widget_1’); } if(isset($display_options[‘header_layout’]) && $display_options[‘header_layout’] == ‘1’) { … Read more

Shortcode to Gutenberg-block: additional text on front-end and conditional display

Although a little different than I had initially anticipated, I have found/created a solution to my two problems. Conditionals I have opted to move non-required input to the sidebar, using the InspectorControls-element. Reason for this is that I realised that it would be impossible to hide a field (in the editor-part of the screen) that … Read more

meta content on required pages

After too many tries i have found following solution myself, but this could save others time. $pid = (isset($_GET[‘post’]) ? $_GET[‘post’] : $_POST[‘post_ID’]); $page_att = get_page( $pid ); $page_parent = $page_att->post_parent; if(15 == $page_parent){ //register metabox }

Add default content to posts in a specific category?

Using the code you posted, the selected category’s ID is available in the $_REQUEST, you can check that ID against your products category in the default_content filter and add content if there’s a match: add_filter( ‘default_content’, ‘wpa70073_default_products_content’ ); function wpa70073_default_products_content( $content ) { // change this to your desired category ID $products_category_id = 42; if( … Read more

Exclude custom function content from certain pages

Check for the type of the page: function get_author_bio ($content=””){ if ( ! is_single() ) // not a blog post, stop immediately { return $content; } global $post; // continue with regular work The easiest way to learn these check functions is a look at the function get_body_class(). Here are the most important: is_rtl() is_front_page() … Read more

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