How to sort wordpress posts by selecting a year from a drop down?

I answered my own question. I’m just a beginner, so the code is trash; I know, don’t judge. What you have to do is create a new query. First, go to your themes category.php file. People need to select the year from your ul/li menu. For me it is: <ul class=”dropdown-menu”> <li class=”nav-item”><a href=”?orderbyyear=2021″ class=”nav-link … Read more

Too few arguments at registering new templates in my plugin

This is the problem, or rather what is missing from it: add_filter( ‘theme_page_templates’, __NAMESPACE__ . ‘\register_plugin_templates’ ); Specifically, you never told it that your function can accept 3 parameters, so it assumed it only accepts 1 as that’s the absolute minimum needed for a filter to work. Then on top of that, none of your … Read more

understanding wp_next_scheduled

You’re probably attempting to add this too early. Wait for init. add_action( ‘init’, function () { if ( ! wp_next_scheduled( ‘send_booking_expiration_hook’ ) ) { wp_schedule_event( strtotime( ’12pm’ ), ‘hourly’, ‘send_booking_expiration_hook’ ); } } );

Remove content links (internal and external), but exclude post at specific categories

To exclude certain categories from the filter function that removes links from the post content, you can modify the function to check the categories of the post before removing the links. Here is an example of how you can modify the function to exclude certain categories: add_filter(‘the_content’, ‘removelink_content’,1); function removelink_content($content=””) { // Get the categories … Read more

Can’t send form data to wpdb when URL has query string

I see a few issues with the code: First, the form action is not set correctly. It should be something like: <form action=”<?php echo esc_url( get_the_permalink() ); ?>” method=”post”> In the PHP code, you are using the wrong table name. You are using the table name ‘invites’ instead of ‘rsvp’. You should change this line: … Read more