Result of Custom WP_Query appears on 404 Page (but result are found!)

I found out its because I used a Input with name=”name” which caused this issue. I believe the name ‘name’ is a keyword in wordpress/php. I replaced the ‘name’ to ‘personname’ then it works as charm. … <input name=”personname” type=”text” value=”” /> … $_POST[‘gsdname’] // multiple time in my code … Best regards Floh

Alter secondary loop to exclude posts from current page category

This one is even more simple. Refer to the WP_Query() category parameters. I think you will want to use ‘category__not_in’. foreach ( $random_posts_cat_array as $random_post_cat ) { if ( $post_cat_slug == $random_post_cat ) { // No posts from this category! $random_posts_query_args[‘category__not_in’] = $post_cat_id; } } Edit So for example if a post is currently on … Read more

How to save the checked boxes?

You can use PHP in your functions.php file to insert inline JavaScript (including jQuery) using WordPress hooks. In your example, you could use the admin_print_scripts-post.php action hook to print your inline jQuery like so: function wpse_admin_print_scripts_edit() { echo “<script>var limit = 2;’ . ‘jQuery(‘input.single-checkbox’).on(‘change’, function(evt) {‘ . ‘if(jQuery(‘input.single-checkbox:checked’).length > limit) {‘ . ‘this.checked = false;’ … Read more

Why isn’t my if/elseif/else working correctly here?

is_category will not process the logic inside the argument list. This: is_category(‘glorkian’ || ‘glork’) The condition is true on all category pages. What I think is happening is that PHP does parse that argument string, but is always going to be true. Try this: var_dump(‘glorkian’ || ‘glork’); Meaning that what you are doing, essentially, is … Read more

Nice scroll to wordpress

wordpress runs jquery in noconflicts mode which means that you either need to write your JS code using the jQuery function call $(document).ready( function() { jQuery(“html”).niceScroll(); } ); or the following syntax which define $ $(document).ready( function($) { $(“html”).niceScroll(); } );

Looking to exclude blog posts from category Previous/Next buttons

You can exclude categories from your posts page using pre_get_posts function exclude_category( $query ) { if ( $query->is_home() && $query->is_main_query() && !is_admin()) { $query->set( ‘cat’, ‘-1347’ ); } } add_action( ‘pre_get_posts’, ‘exclude_category’ ); Might be better to use the category slug or I.D. Same with the tag. There’s also 5 parameters you might want to … Read more

How to display content from post_parent

As stated by the other answer, you can not pass an ID to get_the_content() function. You could fetch the post using get_post(), but there’s also another handy function that you can use to fetch the content: The get_post_field( $field, $post_id, $context ) function is what you’re looking for: $content = apply_filters( ‘the_content’, get_post_field( ‘post_content’, $post->ID … Read more