Exclude posts with certain tags in category archive

You could modify your query on pre_get_posts. Example: // I’d wouldn’t hardcode the tags/category ids, but where to store and // how to retrieve those settings go beyond the scope of this question. define( ‘YIVIS_EXCLUDED_TAG’, 12 ); add_action( ‘pre_get_posts’, ‘yivi_excludes_tags’ ); function yivi_excludes_tags( $query ) { if ( $query->is_category() { $query->set(‘tag’, [ YIVIS_EXCLUDED_TAG * -1 … Read more

How to Query the Top 5 Posts of a specific category?

Well, depending on what you mean by top 5 posts. You can get top most read, top commented, most liked etc. For comments you can just make your query with argument orderby=comment_count If you want the most viewed, first you need to add the views counter like this: /********* Post Views counter ***********/ remove_action( ‘wp_head’, … Read more

How to auto update post title and slug with category name when post status is updated

You need post status transitions, and quite similar with this post: Detect type of post status transition only what you need to do update post title and slug, and this is easy. Update post examples Since you wrote like this: add_filter( ‘the_title’, ‘my_modify_title’, 10, 2 ); function my_modify_title( $title, $id ) { if( in_category( ‘My … Read more

How Can Hide Define Category in Post Contents?

First add get_the_categories filter before the_category(‘ , ‘) then remove it. So it will not effect categories on other places. add_filter( ‘get_the_categories’, ‘remove_selected_categories’ ); the_category(‘ , ‘); remove_filter( ‘get_the_categories’, ‘remove_selected_categories’ ); In callback function check for categories to remove then remove them! function remove_selected_categories( $categories ) { $categories_to_remove = array( ‘years’, ‘genere’ ); //Place the … Read more

How to display get_categories selected category?

You need to save your selection and then call that selected value into your widget() method. Here is an example of what I mean which displays the selected category name and description in the front end. You can use this widget as a base for your own widget. Just a note, this widget requires at … Read more

Get the categorie name of Event Organiser plugin [closed]

Okay I found the solution. A view in the mySQL table helped to understand how the Event Organiser plugin is using WordPress. The Event Categories a just normal categories with the taxonomy event-category. The only function needed is get_term_by(). // Get term by slug ”test-cat” in event-category taxonomy. $cat = get_term_by(‘slug’, $eo_event_loop->query[‘event-category’], ‘event-category’); echo $cat->name; … Read more

Custom field picture instead of post thumbnail on category page

I reckon you use the image URL in your custom field. $metro_creativex_posttitle = get_the_title(); // Not used in this snippet /* // you don’t need this block $metro_creativex_feat_image = wp_get_attachment_image_src( $post->ID, get_field(‘sd_single_img’), ‘single-post-thumbnail’ ); */ // you’ll need `$post_id` for each song $img_src = get_field(‘sd_single_img’, $post_id); if( !empty( $img_src ) ) { // echo if … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)