Displaying the category name of a custom post type
So this is what I needed: <?php $terms = get_the_terms( $post->ID , ‘board’ ); foreach ( $terms as $term ) { echo $term->name; } ?>
So this is what I needed: <?php $terms = get_the_terms( $post->ID , ‘board’ ); foreach ( $terms as $term ) { echo $term->name; } ?>
The offset index for WP_Query generally works with pagination. When you set pagination to a -1 the function assumes you’re getting all posts and there will be no pagination or offset. So to counteract this you would set the posts_per_page to a high number like 999. Reading the Function Reference on WP_Query the pagination section … Read more
As it doesn’t look as though the OP is coming back, I’m adding their answer as an answer rather than leaving it in the question: For everyone dealing with the same problem: I was able to fix it with a code snippet of another thread: https://wordpress.stackexchange.com/a/172556/87321 Just had to add the post status “pending”, so … Read more
Looks like this question is a several months old, but it’s a good one so I’m digging it out of the grave. The way I would go about solving it would be to intercept any searches with the pre_get_posts filter and add in the meta query based on the provided information. Here’s a basic shot … Read more
Your query parameters don’t contain any category arguments. You need to pass and set cat or category_name along with the post type, offset, and posts per page. You can get the current category’s ID via get_queried_object(): $queried_object = get_queried_object(); $cat_id = $queried_object->term_id; Output and retrieve the value somewhere in your category template, or better, when … Read more
This have several components to it – what option itself holds and how value from it is stashed away and reused by various pieces of core code. I am not sure this is perfect, but my quick take would be: new Adjust_Comments_Per_Page( 10, ‘years’, ‘category’ ); class Adjust_Comments_Per_Page { private $amount; private $term; private $taxonomy; … Read more
For a truly full solution you need to have all the users to have an account (or create one when marking as read) and you associate in the DB the user with the posts that he read and then style each link appropriately. To implement this you can look for inspiration in plugins that add … Read more
you can do that with the function wp_handle_sideload https://developer.wordpress.org/reference/functions/wp_handle_sideload/ Steps to make this : create a temporary file with the content you need pass this filename to function wp_handle_sideload
Yes, you can use HTML elements in post titles by default. If your output is escaped a plugin or theme might have touched that. Disable all plugins and switch to TwentyEleven. This will help you to identify the source. Note that markup is stripped in some places where it is not allowed: title attributes and … Read more
My idea is that you can setup a post date for the attachments. This can be done using attachment_fields_to_edit to show the UI (is possible use the touch_time internal function). After that, you can filter all the attachments query to show only the attachments with a past or current date. So add_action(‘load-post.php’, ‘setup_attachment_fields’); function setup_attachment_fields() … Read more