ID); if (empty($categories)) { return ''; // No categories, no related posts. } // Query arguments $args = array( 'category__in' => $categories, 'post__not_in' => array($post->ID), 'posts_per_page' => 1, 'offset' => $number - 1 // Skip the first ($number - 1) posts. ); $related_posts = new WP_Query($args); if ($related_posts->have_posts()) { $related_posts->the_post(); $options = get_option('iap_settings'); // Fetch settings or use defaults $background_color = !empty($options['background_color']) ? esc_attr($options['background_color']) : '#fffdf9'; $border_style = !empty($options['border_style']) ? esc_attr($options['border_style']) : 'dotted'; $border_color = !empty($options['border_color']) ? esc_attr($options['border_color']) : '#9b1717'; $also_read_text_color = !empty($options['also_read_text_color']) ? esc_attr($options['also_read_text_color']) : '#cb0000'; $also_read_text_font_style = !empty($options['also_read_text_font_style']) ? esc_attr($options['also_read_text_font_style']) : 'Arial'; $title_font_style = !empty($options['title_font_style']) ? esc_attr($options['title_font_style']) : 'Arial'; $title_font_color = !empty($options['title_font_color']) ? esc_attr($options['title_font_color']) : '#333'; $copyright_text = !empty($options['copyright_text']) ? $options['copyright_text'] : 'Developed by Mukesh Gusaiana'; // Output the related post HTML $output = '
' . get_the_post_thumbnail(null, 'in-article-post-thumb', array('class' => 'rajudigitalservices-iap-image')) . '
' . get_the_title() . '
'; if (!empty($options['show_copyright'])) { $output .= ''; } $output .= '
'; wp_reset_postdata(); return $output; } else { return ''; // No related posts found. } } // Add settings page function iap_settings_menu() { add_options_page( 'In-Article Posts Settings', 'In-Article Posts', 'manage_options', 'in-article-posts-settings', 'iap_settings_page' ); } add_action('admin_menu', 'iap_settings_menu'); function iap_settings_page() { ?>

In-Article Posts Settings

How to Use

Step by Step Process

1. Download the plugin zip file.

2. Go to your WordPress admin dashboard.

3. Navigate to Plugins > Add New.

4. Click the 'Upload Plugin' button at the top.

5. Select the downloaded zip file and click 'Install Now'.

6. Once installed, click 'Activate Plugin'.

7. Navigate to Settings > In-Article Posts to configure.

About Developer

Mukesh Gusaiana

Mukesh Gusaiana

Contact to Mukesh Gusaiana

For more info,: Call or Whatsapp 8684838921

Feedback

'; } function background_color_callback() { $options = get_option('iap_settings'); echo ''; } function border_style_callback() { $options = get_option('iap_settings'); echo ''; } function border_color_callback() { $options = get_option('iap_settings'); echo ''; } function also_read_text_color_callback() { $options = get_option('iap_settings'); echo ''; } function also_read_text_font_style_callback() { $options = get_option('iap_settings'); $fonts = array('Arial', 'Courier New', 'Georgia', 'Times New Roman', 'Verdana', 'Lohit Telugu', 'Noto Sans Telugu', 'Gidugu'); echo ''; } function title_font_style_callback() { $options = get_option('iap_settings'); $fonts = array('Arial', 'Courier New', 'Georgia', 'Times New Roman', 'Verdana', 'Lohit Telugu', 'Noto Sans Telugu', 'Gidugu'); echo ''; } function title_font_color_callback() { $options = get_option('iap_settings'); echo ''; } function show_copyright_callback() { $options = get_option('iap_settings'); echo ''; } function custom_shortcodes_also_read_count_callback() { $options = get_option('iap_settings'); $value = isset($options['custom_shortcodes_also_read_count']) ? $options['custom_shortcodes_also_read_count'] : 1; echo ''; } function feedback_rating_callback() { $options = get_option('iap_feedback'); $rating = isset($options['feedback_rating']) ? $options['feedback_rating'] : 0; for ($i = 1; $i <= 5; $i++) { echo ' ' . $i . ' '; } } function feedback_description_callback() { $options = get_option('iap_feedback'); echo ''; } function feedback_email_callback() { $options = get_option('iap_feedback'); echo ''; } // Modify post content function iap_modify_content($content) { if (!is_single()) { return $content; } $options = get_option('iap_settings'); if (!empty($options['iap_enable'])) { $also_read_count = isset($options['custom_shortcodes_also_read_count']) ? $options['custom_shortcodes_also_read_count'] : 1; $split_content = explode('

', $content); $num_sections = count($split_content); if ($also_read_count > 0) { $interval = ceil($num_sections / ($also_read_count + 1)); $modified_content = ''; $shortcode_index = 1; foreach ($split_content as $index => $paragraph) { $modified_content .= $paragraph . '

'; if ($shortcode_index <= $also_read_count && ($index + 1) % $interval == 0) { $modified_content .= do_shortcode('[short-code' . $shortcode_index . ']'); $shortcode_index++; } } $content = $modified_content; } else { $content = implode('

', $split_content); } } return $content; } add_filter('the_content', 'iap_modify_content'); // Add settings link on plugin page function iap_settings_link($links) { $settings_link = 'Settings'; array_unshift($links, $settings_link); return $links; } add_filter('plugin_action_links_' . plugin_basename(__FILE__), 'iap_settings_link'); // Enqueue color picker function iap_enqueue_color_picker($hook_suffix) { wp_enqueue_style('wp-color-picker'); wp_enqueue_script('iap-script-handle', plugins_url('iap-script.js', __FILE__), array('wp-color-picker'), false, true); } add_action('admin_enqueue_scripts', 'iap_enqueue_color_picker'); // JavaScript for color picker function iap_add_color_picker_js() { ?>