Tag Info

Hot answers tagged

2

Use the hooks added_term_relationship and deleted_term_relationships. These only fire when the relationship changes, as opposed to set_object_terms which always fires: function wpse_181090_object_terms_updated( $object_id ) { static $did = array(); // This function might fire multiple times for the same object, ensure it only runs once if ( ! ...


1

It think that your problem is the you are passing the post ID as url parameter to facebook API: $url = get_the_ID(); Also, as get_posts return an array of post objects, you could use this code: $posts = get_posts(array('numberposts' => -1) ); foreach($posts as $post) { $url = get_permalink( $post->ID ); $fbcount = json_decode( ...


1

Use in_the_loop() to know if you are currently in the loop of the main query. function after_title($title) { if ( in_the_loop() && ( is_single() || is_page() || is_home() || is_category() ) ) { $write = 'AFTER TITLE'; $title = $title.$write; } return $title; } add_filter( 'the_title', 'after_title' );


1

You are not escaping your PHP correctly. In this part $output="... <?php You could instead do it like this: add_action('wp_head','hook_css'); function hook_css() { ?> <!-- Closing the PHP here --> <style> body { background-repeat: no-repeat; background-attachment: fixed; background-size: 100% 100%; ...


1

A better approach is to use the full URL to the background image. Otherwise the image might not appear on child pages or posts. <?php add_action('wp_head','hook_css'); function hook_css() { $output=" <style> body { background-repeat: no-repeat; background-attachment: fixed; ...



Only top voted, non community-wiki answers of a minimum length are eligible