Remove “Browsed by Category” from Category Page
Add to the style.css (http://deks.org.rs/sanunis/wp-content/themes/nisarg/style.css) of your theme the following: .category h3.archive-page-title { display: none; }
Add to the style.css (http://deks.org.rs/sanunis/wp-content/themes/nisarg/style.css) of your theme the following: .category h3.archive-page-title { display: none; }
Use WP_Query with Taxonomy Parameters. If you want posts that are in both categories, just add two conditions in tax_query (using an array for terms will get you posts that have at least one of those categories). Note that you’ll have to adapt the taxonomy to your needs. Instead of slug, you could also use … Read more
$categories = get_categories( array( ‘parent’ => 0, ) ); foreach ( $categories as $category ) { echo $category->name; $posts = get_posts( array( ‘category_name’ => $category->slug, ‘posts_per_page’ => 3, ) ); foreach ( $posts as $item ) { echo get_the_title( $item->ID ); } } Something like this print wich you need. But it is very simple … Read more
The filter you’re looking for is called wp_terms_checklist_args and is used by wp_terms_checklist() (which is internally called to display the category metabox). You can use this to pre-selected specific categories (by ID) under certain circumstances as shown in this example add_filter(‘wp_terms_checklist_args’, ‘WPSE_pre_select_categories’, 10, 2); function WPSE_pre_select_categories($args, $post_id) { $post = get_post($post_id); // only pre select … Read more
<?php remove_action(‘woocommerce_shop_loop_item_title’, ‘woocommerce_template_loop_product_title’, 10); function loop_title() { global $post;?> <div class=”col-xl-3 col-md-3 col-sm-3″> <h3><a href=”https://wordpress.stackexchange.com/questions/304779/<?php the_permalink(); ?>” class=”feed-item-baslik”><?php the_title(); ?></a></h3> <?php $terms = get_the_terms( $post->ID, ‘product_cat’ ); if ( $terms && ! is_wp_error( $terms ) ) : if ( ! empty( $terms ) ) { echo $terms[0]->name; }?> <?php endif;?> </div> <?php } add_action(‘woocommerce_shop_loop_item_title’, ‘loop_title’, … Read more
Well, there are many things that are not exactly correct with your code: $posts = $wpdb->get_results( “SELECT ID, post_title, post_modified_gmt FROM $wpdb->posts LEFT JOIN $wpdb->term_relationships as t ON ID = t.object_id WHERE post_type=”post” AND post_status=”publish” AND t.term_taxonomy_id = 3 WHERE post_status=”publish” # <– !! second WHERE clause AND post_password = ” AND post_type=”post” # <– … Read more
To get link to category use the function get_category_link (doc here). Function get_permalink is intended for posts. echo ‘<h2 class=”podcast_h2″><a href=”https://wordpress.stackexchange.com/questions/310553/” .get_category_link($category->term_id). “https://wordpress.stackexchange.com/questions/310553/”> ‘.$category->name.’ </a></h2>’
OK, so you’ve put this code on category archive, I assume, and the dropdown always shows the same category, right? And it’s exactly what it’s supposed to do with current code. In this line: ‘selected’ => 1, you decide, that item with value 1 is selected. Probably there is no such value (1 doesn’t occur … Read more
Problem with your code is that you don’t modify queries at all in any way, so all queries on your site still get these posts – so they are visible on lists. And later, you use template_include filter which allows you to redirect single post view and single category archive if it shouldn’t be visible … Read more
WordPress doesn’t record the visit statistics in the database. If you want to show top visited categories, you must then record statistics somewhere. What’s why there are plugins designed to fill out this need. Of course, you can write your own code to record visits in the database. This will be a good starting point.