Post Filtering by GET URL parameters

You have to filter the posts in the query arguments. Try: $mycat = $_GET[‘category’]; $arg = array( ‘type’ => ‘post’, ‘order’ => ‘ASC’, ‘category_name’ => $mycat ); Just remove the square brackets from the link, or use: $mycat[0] $mycat = $_GET[‘category’]; $arg = array( ‘type’ => ‘post’, ‘order’ => ‘ASC’, ‘category_name’ => $mycat[0] );

Count several post tags

How do I write if I would like to know how many posts there are in 10 different tags together? If you mean the combined total number of posts, i.e. the sum of the count value of each term, then: Yes, you can put the slug list in an array and loop through the items … Read more

Why this function doesn’t works without the_post?

I’m just going to quote a brief, yet comprehensive, comment on the official reference page for the_post(): Function the_post() checks whether the loop has started and then sets the current post by moving, each time, to the next post in the queue. Additionally, the “current post” here refers to the current item in WP_Query::$posts which … Read more

Hook for changing excerpt content when excerpt not set

The proper hooks for modifying the post excerpt are the ones you already tried: get_the_excerpt and the_excerpt, and WordPress actually uses the former one to generate an excerpt from the full post content, if there’s no custom or manually-specified excerpt for the post — below is the relevant code in wp-includes/default-filters.php: add_filter( ‘get_the_excerpt’, ‘wp_trim_excerpt’, 10, … Read more

Add to ‘action’ within post.php to allow more actions when editing a Custom Post Type in a plugin

Create custom actions with add_filter(post_action_{$action}); Even if it’s just to test, editing core files is bad practice. I prefer to download the source code onto my own machine and find where and how the hooks are firing. Anyway, there is very poor documentation in this part of the source code, but I’ve been studying it … Read more

See if a post has a specified tag

You should wrap your condition with brackets according to PHP syntax: if (has_tag(‘Cat’, $post_id)) { $taganimal = “Cat”; } If you need to check multiple tags you can use something like foreach ([‘Cat’, ‘Dog’] as $animal) if (has_tag($animal, $post_id)) { $taganimal = $animal; break; } but it would find only the first tag listed in … Read more

How to add automatically bootstrap 4 order-lg-1 and order-lg-2 classes for columns in foreach loop based on the count?

You should use the PHP modulo operator for that. Since you need two different layouts, you should calculate your classes numbers according to $count % 2 and ($count + 1) % 2: <?php $count = 0; foreach ($howtoplaycontent as $hpc): ?> <div class=”row courses_row” style=”background-color: #f8f8f8″> <div class=”container”> <div class=”row” style=”padding: 15px;”> <div class=”col-lg-6 course_col … Read more

Disable posts generated from image uploads

There are a few ways to do this with updates to functions.php as well but the easiest might be to first install Yoast plugin and then use the setting for Attachment URLS that redirect it to the parent post https://yoast.com/media-attachment-urls/

Blog page error ‘Index of /blog’

There shouldn’t be a blog folder in the file manager. If there is one, your web server will load that instead of asking WordPress for the blog page. Delete the empty folder and it will work. You should never need to create folders or pages in the file manager or via FTP when using WordPress.

Reinstall WordPress while keeping attachments

Depending on how those inbound links work, this could be simpler than you think. If the links are direct to files in the file system, WordPress isn’t actually needed at all – just a corresponding path for a valid URL. So let’s say you install WP today, the ‘earliest’ folder in uploads will be 2020/09. … Read more