How Display Posts on category

You should look at the WordPress Template Hierarchy. If you want to show an archive of your posts you create a template called archive-mahsulat.php where mahsulat is your post type. Then you can add a normal WordPress Loop to the file so it can output posts of that type. If you’re looking to create a … Read more

Convert HTML Script to Shortcode [closed]

Your JavaScript targets a HTML element with the id ‘banner_div’. So the first step is to output such an element in the shortcode. add_shortcode( ‘shortcode_name’, function () { $out=”<div id=”banner_div’></div>’; return $out; } ); Now you need to save the JavaScript (everything between the <script> tags) as a file. This you can now enqueue which … Read more

Adding JavaScript to a WordPress website

Using this link, you will find helpful notes as to how to add a script to your WordPress website. The main idea is to use inbuilt WordPress functions to load your scripts. This is done via the wp_enqueue_script function. Following examples provided in the aforementioned link, you will be able to learn how to enqueue … Read more

Missing sidebar parameter “fix” – before_content

This code detects whether a title has been set, and if not, it changes the before_widget argument. add_filter( ‘widget_display_callback’, ‘wpse4213_widget_display_callback’, 10, 3 ); function wpse4213_widget_display_callback( $instance, $widget, $args ) { if ( empty( $instance[‘title’] ) ) { $args[‘before_widget’] = ‘<div class=”container”><div class=”content”>’; $widget->widget( $args, $instance ); return false; } return $instance; } This code works … Read more

Removing unneccessary p-tags (Not every p)

If what you want is really only to prevent WordPress from adding empty <p></p> and you’d be happy with removing those after post retrieval from the database, then function wpse108194_remove_empty_paragraphs( $content ) { $content = preg_replace( ‘#<p>\s*</p>#’, ”, $content ); return $content; } add_filter( ‘the_content’, ‘wpse108194_remove_empty_paragraphs’, 11 ); will do.