WordPress connecting posts

Check out Posts 2 Posts. It’s older, but it’s rock solid and saves a ton of work. There’s a github library and a plugin, depending on how you plan to implement it. https://github.com/scribu/wp-posts-to-posts https://wordpress.org/plugins/posts-to-posts/ Good luck.

Related post based on 2 categories

You can do it like below- $query = get_posts( array( ‘category__and’ => array( 6, // Your category-1 ID 7 // Your category-2 ID // And so on and so fourth ) ) ); Now in $query variable you’ll get the object of posts which are in both Category 1 and Category 2 and so on … Read more

How can I add a custom checkbox / radio button on the admin theme options to display a CSS or other?

This is a fairly broad question. There are many approaches thinkable, but here is the lay-out for an easy one: Build a child theme, consisting only of a style.css. Find the id of the highest level wrapper in the theme, let’s say 2016id In style.css add style rules that depend on the class of the … Read more

How to add styling and script to a custom widget plugin

You can use wp_enqueue_script and wp_enqueue_style just after the following code add_action(‘widgets_init’, function(){ register_widget(‘calendar_widget’); }); You can add js/css like this function mg_scripts() { wp_enqueue_style( ‘style-name’, ‘/path/to/css’ ); wp_enqueue_script( ‘script-name’, ‘/path/to/js’, array(), ‘1.0.0’, true ); } add_action( ‘wp_enqueue_scripts’, ‘mg_scripts’ ); You can also call wp_enqueue_script and wp_enqueue_style directly inside widget function like this <?php /* … Read more

how to add custom css at top above all css file for specific url

/** * Enqueue stylesheet before others */ class EnqueueStylesheetEarly { function __construct() { add_action( ‘wp_enqueue_scripts’, [ $this, ‘load_before_other_stylesheets’ ], 5 ); } /** * Register and enqueue stylesheet */ function load_before_other_stylesheets() { wp_register_style( ‘bootstrap-css’, plugin_dir_url( __FILE__ ) . ‘bootstrap.min.css’, [], ‘3.3.7’ ); wp_enqueue_style( ‘bootstrap-css’ ); } } Then you can load this with your other … Read more