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

Simple Plugin with custom javascript wont work – no console error

You could “borrow” the html form from the example and include this in your template – either directly of via a filter like wp_footer: <form method=”GET” action=”/javascript/search-highlight/” onsubmit=”myHilitor.apply(hilite.value); return false;”> <fieldset> <legend>Highlight Words</legend> <label>Keywords</label><span><input type=”text” size=”32″ name=”hilite” value=”search engine keywords”> <input type=”submit” value=”Apply”> <input type=”button” value=”Remove” onclick=”myHilitor.remove();”></span> </fieldset> </form>

How do I display a user’s previous orders as a select box option on a product?

You can try something like this: add_action( ‘woocommerce_before_add_to_cart_form’, ‘add_list_completed_orders’ ); function add_list_completed_orders() { // get orders $orders = wc_get_orders ( array ( ‘status’ => array( ‘wc-completed’ ), ‘type’ => ‘shop_order’, ‘limit’ => -1, ‘return’ => ‘ids’, ‘customer_id’ => get_current_user_id(), ) ); if ( ! empty( $orders ) ) { // set value options $options=””; foreach … Read more

Can’t extend some core classes

You can extend it, but the class definition and any code that uses it, can’t run outside of the admin area. Wrap your class in this conditional: if ( is_admin() ) { … } If you are trying to use this on the frontend or other non-Admin areas, do not do that. Generally, classes WordPress … Read more

Create shortcodes within foreach loop (using array)

Solved issue of dynamic function name by using $shortcode var as function name foreach ($shortcodes as $shortcode) { add_shortcode($shortcode, function ($atts) use ($shortcode) { $filepath = str_replace(‘_’, ‘-‘, $shortcode); ob_start(); require_once(get_stylesheet_directory() . ‘/template-parts/’ . $filepath . ‘.php’); return ob_get_clean(); }); }

Use object in template part

As of WordPress 5.5 you can pass variables to template parts by passing them in an array to the third argument of get_template_part(): foreach ($categories as $category) { get_template_part( ‘temp-parts/loop/blcnr_loop’, null, [ ‘category’ => $category ] ); } These variables will populate an $args variable accessible from the the template: echo $args[‘category’]->name;

Randomise upload filenames (or another solution to hide the original image URL from theft?)

Where am I going wrong? Actually, your code is just fine. Except that I would simply use wp_generate_password() to generate the random string. 🙂 WordPress will still think that the scaled version is called painting-scaled.jpg , etc. Resulting in broken images. Yes, that’s correct. Images are stored as posts of the attachment type in the … Read more

How to update wp-config file in Docker

The Solution that finally worked was to turn down the containers using docker-compose down command. I was not detaching the containers, but I still need to turn them down. Once I did so, I then run the command docker volume ls to list all the volume and delete the one with WordPress data in it … Read more