How php content after the first and second paragraph

I found a way to make a call to a get_template_part. <?php $paragraphAfter[1] = ‘<div><?php get_template_part( “part-related”, “ad-first” ); ?></div>’; //display after the first paragraph $paragraphAfter[3] = ‘<div><?php get_template_part( “part-related”, “ad-third” ); ?></div>’; //display after the third paragraph $paragraphAfter[5] = ‘<div><?php get_template_part( “part-related”, “ad-fifth” ); ?></div>’; //display after the fifth paragraph $content = apply_filters( ‘the_content’, … Read more

Use wc_enqueue_js only on specific pages – nested add_action

No idea why, but for the second snippet, changing the priority of the nested add_action from the default (10) to 20, causing the parent and child add_action to have a different priority solved the problem and now everything works perfectly: add_action( ‘template_redirect’, function() use ( $args ) { acau_enqueue_script ( $args ); }, 20); The … Read more

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

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