WordPress forms submissions and PHP files

Have you try with admin-post.php for your form submission. admin_post hook available in WordPress gives you great control over the flow of execution for your form. Using the above form, the following HTML content would execute the above hook when the user clicks either Submit. <form action=”http://www.example.com/wp-admin/admin-post.php” method=”post”> <input type=”hidden” name=”action” value=”custom_form”> <input type=”hidden” name=”data” … Read more

Creating shortcode id for custom post types

Please replace the following code $string .= ‘<li>’ . get_the_title() . ‘</li>’;. to: $string .= ‘<li>’; $string .= ‘<figure>’ . get_the_post_thumbnail( null, ‘thumbnail’ ) . ‘</figure>’; $string .= ‘<h2>’ . get_the_title() . ‘</h2>’; $string .= ‘<div>’ . apply_filters( ‘the_content’, get_the_content() ) . ‘</div>’; $string .= ‘</li>’; Hope it’ll work just fine.

Need help with Code Correction php+wordpress

I see that you try to make some buttons with the links of the previous and the next publication, wordpress has many ways to get those links with functions, I will show you 4: // You are two functions print a tag with its respective link // Previous publication get_previous_post_link(); // Next post get_next_post_link(); With … Read more

Get the_content surrounded by instead of

First you should use get_the_content() to assign the content to a variable (instead of the_content() which is meant to display it instead of returning it). Then you will want to apply filters hooked to ‘the_content’ just like the_content() does (see the source). Here is a revised version of your original code: $thisPagesContent = get_the_content(); $thisPagesContent … Read more

Passing an array into WP_Query as a variable

First of all, you have a typo in your code. The variable with post IDs is called post_id_array, but your foreach loop uses post_ids_array (ids instead of id). When you fix this, then there’s one more problem. Meta query param should be an array of queries and each query should be an array. But your … Read more

How to display success message correctly and delete it when the page is refreshed

You’re looking for Flash Messages. Flash Messages are messages stored in session and deleted right after they are retrieved. You can find some implementation on github: https://github.com/plasticbrain/PhpFlashMessages <?php // Start a Session // Read about managing session with WordPress // Instantiate the class $fm = new \Plasticbrain\FlashMessages\FlashMessages(); // Process form e.g. send an email and … Read more

entire JS folder not loading in a WP theme

The problem is die(). You can’t die() inside a template or it will stop the entire site loading at that point. If you looked closer you’d notice that it wasn’t just the JS folder that wasn’t loading, it was the whole footer. You need to separate you code into 2 functions. One that outputs the … Read more

Post not populating for custom post type based on category selection

But this part is not executing → $args = array( ‘category_name’ => $taxonomy, ‘post_type’ => ‘video’, ‘posts_per_page’ => -1, It probably is. It’s just wrong. If you want to query posts by terms in a custom taxonomy you need to add a taxonomy query: $args = array( ‘post_type’ => ‘video’, ‘posts_per_page’ => -1, ‘tax_query’ => … Read more