Ajax filter button display all posts

Going by what @JacobPeattie said, that they are still set but empty you need to change the conditional login to check for empty. In our previous discussion I wrote this conditions if ((isset($_POST[‘categoryfilter1’]) && !empty($_POST[‘categoryfilter1’])) && (isset($_POST[‘categoryfilter2’]) && !empty($_POST[‘categoryfilter2’]))) { // both properties are set and have value (not empty) } elseif ((isset($_POST[‘categoryfilter1’]) && !empty($_POST[‘categoryfilter1’])) … Read more

Add meta tags to a custom header

HTTP headers are different than the HTML head. The meta tag you’re looking to add (for the Twitter card) is actually a meta tag that gets place in the HTML head. So to achieve exactly what you’re looking to do from a PHP “functions” file, you’d want to hook into wp_head instead. Like this: add_action(‘wp_head’, … Read more

Divi change project category slug

add_filter( ‘register_taxonomy_args’, ‘change_taxonomies_slug’, 10, 2 ); function change_taxonomies_slug( $args, $taxonomy ) { if ( ‘project_category’ === $taxonomy ) { $args[‘rewrite’][‘slug’] = ‘stainless-steel-products’; } return $args; }

How to: Conditionally Enqueue JS and Stylesheets, for Custom Post Type (Single and Archive Templates)

Try using is_post_type_archive() and is_singular(): // … if ( is_post_type_archive( ‘my-post-type’ ) || is_singular( ‘my-post-type’ ) ) { // your enqueue code goes here } // … These functions will check to see if you’re on, respectively, an archive page for the post type my-post-type or a single my-post-type post. (Change the my-post-type to what … Read more

Most commented posts by time period (last 12h, last 24h and etc)

So if you want to get the posts that were commented within the last xx hours, e.g. 12 hours, then try one of the following: Note though, I’m selecting only published posts (post_status=”publish”) and of the post type (post_type=”post”). And just replace the value of $hours with your preferred number of hours. Using TIMESTAMPDIFF(). $hours … Read more

Referencing Images in javascript to display on wordpress page

The problem is that you are trying to use PHP inside a javascript file. PHP only works inside .php files. If you want to pass information to your javascript file from PHP, use wp_localize_script to store it in a variable, e.g. in a PHP file: $values = array( ‘foo’ => ‘bar’, ); wp_localize_script( ‘yourscripthandle’, ‘objectname’, … Read more

WordPress query undefined offset in loop

There might be other causes to the issue in question, but one issue I noticed in your code is that because you are looping through a custom WP_Query instance, i.e. $loop, then you need to use $loop->the_post() instead of just the_post(): while ( $loop->have_posts() ) { $loop->the_post(); the_title(); } And you could see that I … Read more

Fixing Deprecated: get_the_author_lastname

Note: I’m not simply giving you the full fixed code, but the line in which you need to make the changes is the one with the <span class=”Z3988″ …>. So yes, both get_the_author_firstname() and get_the_author_lastname() have been deprecated and as said in the error, you should instead be using get_the_author_meta(). And in the coinsify_the_content() function, … Read more

Large WordPress CRON job

I can’t schedule (I don’t know how I should do it) separately CRON jobs because I had a few situations when some function was run before I have necessary data The key to doing this is scheduling the first job to run daily at the required time, and have that event create all of the … Read more