Get sticky post from category?

Use the below code in the mainpage template to show the sticky posts. <?php $args = array( ‘cat’ => 42, ‘posts_per_page’ => 10, ‘post__in’ => get_option( ‘sticky_posts’ ), ); // The Query $the_query = new WP_Query( $args ); // The Loop while ( $the_query->have_posts() ) { $the_query->the_post(); echo ‘<li>’ . get_the_title() . ‘</li>’; } The … Read more

Removed slug from CPT, now How/where do I hook the filter to the taxonomy term archive pages link?

This worked fine for me, except the whole system above has some issue with my configuration (I made my wp installation Multisite) that broke all the other posts. They are all not-found, although the permalink is retrieved correctly every time, as it was found. I’m opening a new question for that other issue here so … Read more

hide specific categories from showing

I haven’t tested this, so it might need to be tweaked (specifically, I’m not sure if I got the names of the params right on the term object), but this should get you most of the way there. //add filter add_filter( ‘get_the_terms’, ‘my_exclude_terms’, 10, 1 ); //function to do filtering function my_exclude_terms( $terms ) { … Read more

Select category in custom query

I would do this in two pieces. Add this into your functions.php file to grab custom fields globally: function get_custom_field($key, $echo = FALSE) { global $post; $custom_field = get_post_meta($post->ID, $key, true); if ($echo == FALSE) return $custom_field; echo $custom_field; } Build your query as follows: I can’t seem to get markdown to play nice, so … Read more

Disable pagination only for specific category

You can try this, replacing my_cat with your category slug. This will modify the main query just before rendering the loop on the archive page of your category. add_action( ‘pre_get_posts’, ‘wpse_disable_pagination’ ); function wpse_disable_pagination( $query ) { if( is_category( ‘my_cat’ ) { query->set( ‘posts_per_page’, ‘-1’ ); } }

Categories and Tags returning 404 on the sidebar when using ugly permalinks

Instead of: home_url() . “/tag/” . $i->slug Use get_term_link() function. It will return the link for the term according with the current configuration: // Assuming $i is a term object get_term_link( $i->term_id ) For example, your printTags() function would be: function printTags($tags){ //Check to see if tags are provided if ($tags!=false) { $return = ”; … Read more

How can I make wp_list_categories output li with category-slug as class, for its children?

I am not sure if querying the categories again is the good idea. The following code extends the Walker_Category and makes use of it to do the replacement. Put the following in your functions.php: class WPSE67791_Walker_Category extends Walker_Category { public function start_el(&$output, $category, $depth, $args) { parent::start_el( $output, $category, $depth, $args ); $find = ‘cat-item-‘ … Read more

Order posts by category name

I had the same struggle like you, thank i sat down and rethought the whole thing, what you actually need to is select all the categories, and pass the category id to it. Since you use a dlm_download you will need to do the following, get the terms from the dlm_download_category $cats = get_terms(‘dlm_download_category’); Loop … Read more