Javascript code for Category

Write this in your theme’s functions.php file function category_enqueue_script() { $cat_education_id = ‘xx’; // category id for “education” $cat_dog_id = ‘yy’; // category id for “dog” if ( is_category() && ( is_category( $cat_education_id ) || is_category( $cat_dog_id ) ) ) { wp_enqueue_script( ‘my-js’, ‘filename.js’, false ); } } add_action( ‘wp_enqueue_scripts’, ‘category_enqueue_script’ );

How do I add and display a custom image field to a category? [duplicate]

I have used ACF – Advanced Custom Fields for this multiple times ( http://www.advancedcustomfields.com/resources/how-to-get-values-from-a-taxonomy-term/ ). The problem with taxonomy images & other custom fields is that the values are stored in wp_options table. In bigger sites this will populate the wp_options table a lot and is probably not the most efficient way to store data. … Read more

Random post order into Category Pages

You can use the following line of code in your category.php file for Random posts. <ul> <?php $posts = get_posts(‘orderby=rand&numberposts=5’); foreach($posts as $post) { ?> <li><a href=”https://wordpress.stackexchange.com/questions/169519/<?php the_permalink(); ?>” title=”<?php the_title(); ?>”><?php the_title(); ?></a> </li> <?php } ?> </ul> </li>