Echo a shortcode div after every 3 posts

First, let’s clean up this tag SPAM nightmare so we can read it and then simplify the code: function adinserter() { return ‘abcdefg’; } if (have_posts()) { $count = 0; while (have_posts()) { the_post(); $count++; get_template_part( ‘content’, get_post_format() ); if ($count == 3) { if (function_exists (‘adinserter’)) { echo adinserter (1); } $count = 0; … Read more

Get html data with javascript to php array and store to wordpress database

Here is my own solution. In my html I’ve assign id to all the item and inside the form I’ve added an input option where I pass the value through the script and it was saved later. Simple… script jQuery(document).ready(function($){ $(“.sortable”).sortable({ connectWith: ‘.sortable’, receive: function (event, ui) { document.getElementById(‘hello1’).value = myFunction(); }, out: function (event, … Read more

how to disabled a button when press three times

Use Javascript, on the click event write in a new variable and count the click. If is equal with 3, then add the attribute to the button, that people can’t use this. As simple example with the help of jQuery. I think jQuery is much better, is always active in the back end of WordPress. … Read more

How to pass a PHP $_GET variable and fetch/output it?

get_query_var() only works with the Core WP_Query object: Retrieve public query variable in the WP_Query class of the global $wp_query object. https://codex.wordpress.org/Function_Reference/get_query_var Your mistake is a simple PHP one: The key is foo, not bar. $foo = $_GET[‘foo’]; echo $foo; But please do not echo user supplied data to the page without sanitizing it.

How to add div blocks after certain set of post

use % to set the template(style) or you can use :nth-child(16n+1) … <?php if (have_posts()) : ?> <?php $count = 0; ?> <?php $st = 16; //after how many blocks you want to repeat the pattern <?php while (have_posts()) : the_post(); ?> <?php $count++; ?> <?php if ($count%$st == 1) : ?> <div class=”style-1″><?php the_content(); … Read more

Logic on a Gravity Forms redirect [closed]

If anyone runs into this problem, the answer lies in the fact that gform_confirmation is fired after gform_after_submission. The logic is correct, however, the 5th session variable was not being stored before the confirmation was sent. Therefore, no variable ever equaled ‘No’ and it failed every time. The solution is to call the $entry in … Read more

Running rmdir function on post save

Add this to your theme’s functions.php file: function wpse202681_save_post_action($post_id, $post_object, $update) { $folder = “/temp/files/”; delFolder($folder); } add_action( ‘save_post’, ‘wpse202681_save_post_action’, 10, 3 ); // + delFolder() function definition You will probably have to alter folder paths depending on your /temp/files/ location. This will execute everytime any post is saved. You can restrict it to only … Read more

How to use theme function in post/page?

Whenever using any WordPress function with get_xyz_etc() make sure you ECHO the function if you want to output the value there: <img class=”first-slide” src=”https://wordpress.stackexchange.com/questions/203434/<?php echo get_template_directory_uri() .”/images/landing-banner.png’; ?>” alt=”First slide”> It will now output the path!

Writing PHP code in pages without issue?

Writing code in a WP post is not a good idea. As czerspalace mentions the easiest solution is to use a Custom Field to paste the code and use a Shortcode to render it in HTML. The post would be like: Any number of shortcodes can be used, just put a unique name for each … Read more