Can’t get CSS Into the Head via add_action

You don’t call enqueue or register functions hooking into the wp_head hook. At that hook its too late to add more, I guess, unless you play with priority parameter. Use the init hook to call wp_enqueue_* & wp_register_* functions. Do it like this: <?php add_action(‘wp_enqueue_scripts’, ‘addCSS’); function addCSS() { wp_register_style( ‘prefix-style’, plugins_url(‘AddToCartStyles.css’, __FILE__) ); wp_enqueue_style( … Read more

WordPress : Explain Plugins & Theme string value in database

The value is a serialized php array. Further explanation is not really WordPress specific, but here you go — the ‘s’ is the length of the string representation of the succeeding array element (the length of the string in quotes). I.E. in a:2:{s:12:”twentyeleven”;s:7:”/themes”;s:9:”twentyten”;s:7:”/themes”;} the “12” in s:12 represents the length of twentyeleven.

How do I add a favicon that only shows during viewing of my plugin’s admin panel?

When you add your admin (sub)page, then you’re (hopfully) using add_*menu_page(). You can simply save its result in a var. This var is the $hook_suffix. Then you can simply add your callback (that adds the favicon) to the admin_head-{$suffix} hook Source Link. As the plugins screenshot shows you, there’re also the load-{$hook_suffix}-hooks Source Link, which … Read more

List the authors that have written posts in a category

I found a solution. CODE: <?php $cat_arr = get_categories(); // Get the list of Categories foreach ($cat_arr as $cat_obj) { $term_id = $cat_obj->term_id; // Print the Name ?> <br> CAT NAME: <?php echo $cat_obj->name ?>, AUTHOR: <?php // Get all Posts of that Category $posts = get_posts(array(‘category’=>$term_id)); $authors_arr = array(); foreach ($posts as $post_obj) { … Read more

How to get the permanent link in a plugin?

globalize $post to get the current post’s data. also, you want get_permalink, which returns the permalink, rather than the_permalink, which directly echoes the permalink. function abcd_add_contents($content) { if (is_single()) { global $post; $extra_content = get_permalink( $post->ID ); $content .= $extra_content; } return $content; } add_filter(‘the_content’, ‘abcd_add_contents’);

wp_get_post_terms Order by not working

Your title is wp_get_post_terms Order by not working but if you use a custom post type you need to use wp_get_object_terms() I’m not sure what your aim is, but here is a code example you can try: $my_post_type=”post”; // edit this $my_taxonomy=”category”; // edit this $my_query = new WP_Query(array(‘post_type’ => $my_post_type,’posts_per_page’=>10)); if ($my_query->have_posts()) : while … Read more

Class variables not correct on page

When you write that code <?php $pageopi = new opi; ?> // 1. object created // 2. __construct is called // 3. init action hook is set but is never executed so is o_check method <?php echo $pageopi->mg; ?> At this stage, init hook was executed long time before $pageopi is created actually, when page … Read more