Add/echo div with Analytics-Code to function in functions.php

echo (‘<div onClick=”ga(‘send’, ‘event’, ‘will-ich-haben’, ‘klick’, ‘test-klick’);”>’); I haven’t looked any further but as a first step, this string isn’t concatenated correctly. echo “<div onClick=’ga(‘send’, ‘event’, ‘will-ich-haben’, ‘klick’, ‘test-klick’)’></div>”;

Remove Menu Page Giving Error

Put the add_action line inside the if (!current_user_can(‘activate_plugins’) ) {: <?php /************ Remove admin menu items from anyone who isn’t an admin ************/ if (!current_user_can(‘activate_plugins’) ) { function my_remove_menu_pages() { remove_menu_page(‘link-manager.php’); remove_menu_page(‘tools.php’); remove_menu_page(‘edit-comments.php’); } add_action( ‘admin_menu’, ‘my_remove_menu_pages’ ); }; ?>

How to override filter in child theme?

I do not see you actually calling child_remove_parent_function() in your code. Another issue to be aware of is timing. It is counter–intuitive, but functions.php files are loaded in order of child first, parent second. Overall you need to ensure two things: code works at all it is called at the appropriate moment, after parent theme … Read more

Simple/basic use of get_current_screen

I haven’t tested this but theoretically you could do something like this (Using the Codex as an Example): function load_custom_wp_admin_style() { $pageArr = array(1, 2, 3); if(isset($_GET[‘post’]) && in_array($_GET[‘post’], $pageArr)){ wp_register_style( ‘custom_wp_admin_css’, get_template_directory_uri() . ‘/admin-style.css’, false, ‘1.0.0’ ); wp_enqueue_style( ‘custom_wp_admin_css’ ); } } add_action( ‘admin_enqueue_scripts’, ‘load_custom_wp_admin_style’ ); We get the current screen and set the … Read more

Functions.php: If its single?

add_filter(‘wpseo_set_title’, ‘wpseo_set_title_callback’); function wpseo_set_title_callback($input) { if (is_single()) { return ‘Now Single’; } // return default return $input; } Or example from wpSEO Hilfecenter: add_action(‘init’, ‘wpseo_set_title’); function wpseo_set_title() { add_filter( ‘wpseo_set_title’, ‘wpseo_set_title_callback’ ); } function wpseo_set_title_callback($input) { if (is_single()) { return ‘Now Single’; } // Else return default: return ‘Das Buch “‘. $input . ‘” probelesen.’; … Read more

Show last 5 posts from specific category

Here is the correct way to run this. I am using ‘category_name’ in theme code lately as it is much easier to read and remember. It uses the category slug. Here I am retrieving the last 5 posts in “uncategorized”. function Last5posts() { $args = array( ‘posts_per_page’ => 5, ‘category_name’ => ‘uncategorized’); $last_5_posts_query = new … Read more