How to add condition in wordpress loop? [closed]

You don’t even need to write a conditional. This can be done by CSS. Let’s have a simple example. Assuming your post’s structure is like this: <div class=”container-class”> <p> <img src=”https://wordpress.stackexchange.com/questions/275291/some-path”/> Some text </p> </div> You can set a rule to float the first image to left, and the second one to right: .container-class img{ … Read more

Pass php dynamic variable to shortcode

I see a few errors in your code… on the html, there was no quotation in front of variable on the php you say you were calling the short code [modifycontent] but by your php you should have been using [mc]. All the same, here’s how I would do it: function modifycontent ($atts, $content = … Read more

Post + form + action + results on the same page

Use this code <?php if(isset($_REQUEST[‘submit_btn’])) { echo “<div>”; $name = $_POST[“names”]; echo “</div>”; $ins=”insert into tablename (fieldname)values(‘$name’) “; $conn->query($ins); ?> <script> alert(‘inserted successfully’); </script> <?php $sel=”select * from tablename”; $r=$conn->query($sel); while($u=$r->fetch_object()) { echo $u->fieldname; } } ?> <form action=”” method=”POST”> <input type=”text” name=”names” id=”names”> <input type=”submit” value=”submit” name=”submit_btn”> </form> Hope this will help you

I want to add custom add to cart link [closed]

Your problem is that get_page_by_path() returns a WP_Post object, not a WC_Product object. You need a WC_Product object, because that’s the object that contains the product_type property. You can get a WC_Product from a WP_Post via the wc_get_product() function: $post_obj = get_page_by_path( $slug, OBJECT, ‘product’ ); // this code help me to get product detials … Read more

Function to capture a value and store it in a variable

I had a similar task with Contact Form 7, my approach was to add a hidden field to the form in CF7 and then write some jQuery to assign the value to the hidden field when the page was ready. <script> jQuery(document).Ready(function(){ document.getElementById(‘hiddeninputID’).value = document.getElementById(‘cphone’).value; }); </script> Using the above script is the simplest way … Read more

WP Cron job timeout issues

In my opinion function that works 10min is not a best idea. Can You maybe refactor Your function or simply try to build batch processing? My favorite article about that: https://pippinsplugins.com/batch-processing-for-big-data/