Hide HTML element (by class or ID) with PHP

As per our discussion in the comments, all you really need to do is .remove() the element. The following is the approach I’d take. First I’d check to make sure the element exists before attempting to remove it. If it’s there, then run jQuery’s .remove(). if( $( ‘#elementID’ ).length > 0 ) { $( ‘#elementID’ … Read more

How to use html inside a functions.php code?

function misha_loadmore_ajax_handler() { $args = json_decode ( stripslashes ( $_POST[ ‘query’ ] ), true ); $args[ ‘paged’ ] = $_POST[ ‘page’ ] + 1; $args[ ‘post_status’ ] = ‘publish’; query_posts ( $args ); if( have_posts () ) :while ( have_posts () ): the_post (); ?> <div class=”griditem”> <a class=”producturl” href=”<?php the_permalink (); ?>”> <div class=”productimagewrapper”> … Read more

How to check if the current page is at a specified path in the URL?

You could try this instead if (!is_front_page() && is_home()) { get_template_part(‘template-parts/blog-categories’); } Explanation for the difference between front_page an home is here: https://wordpress.stackexchange.com/a/239838 if you set a page as a blog-page it is “home”, in your case the landing-page is the so called “front_page”. This is WordPress specific.

Search WordPress using static html page

If you want to submit a form you need a <form> element to contain the input. (You can get away without one but you’d need script to fake the submit.) The action is the homepage with the search text in an input named ‘s’, e.g. <form method=”get” action=”https://example.com/”> <input type=”search” name=”s” /> <input type=”submit” value=”Search” … Read more

How to use a custom hook

The problem is the order of execution. The order things run matters. For your code to function, it would require either add_action to implement time travel several microseconds into the past so that it can add the hook before it ran, or it would require do_action to implement precognition so that it knows about add_action … Read more

Display related posts without a plugin

I slightly modified your code and tested on my WordPress installation. If you using a filter, like ‘the_content’, which recieves a content as an argument, you must also return this content back. Here is working version of your function with comments. //this filter recieves $content, which you should always return, //otherwise you will not see … Read more