Let users comment on categories in WordPress

For all I know, that’s not possible, since comments depend on a Post ID to exist. You can, however, mimic that functionality by registering a post_type to be at the same time, attached to one specific category, and parent their comments. Then you can insert a secondary query on your comments.php to fetch the post_type … Read more

get_categories only getting categories in the main language

I have a solution if you are using WPML for the multi-language support, i have used this code before. Modified after your taxonomy. <?php //Get categories from current language //Uses WPML Multi-language $terms = get_terms(‘jw_portfolio_categories’,’hide_empty=1′ ); if ( !empty( $terms ) ) { $term_links = “”; foreach ( $terms as $term ) { if( $term->term_id … Read more

Rewrite rules for using the same base slug for multiple content types

Ok, the solution here turned out to be setting the correct priority on the add_action hook. Since we’re all hooking into init to register our post types per the Codex, the priority will determine which register_post_type function gets called first and, by extension, the order of the generated rewrite rules. So, I needed my “gemstone” … Read more

wordpress theme option in other templates

If you are using some custom global theme options, I’d set them in functions.php. Then you access them from any template if you declare them global first. // functions.php <?php $aagt_fb_url=”foo”; – // template file like header.php, index.php, etc. <?php global $aagt_fb_url; echo $aagt_fb_url;

Show page title just from the first child-page in template

Use WP_Query class to do it: $the_query = new WP_Query( array( ‘post_parent’ => $post->ID, ‘post_type’ => ‘page’, ‘posts_per_page’ => 1, ) ); // The Loop while ( $the_query->have_posts() ) : $the_query->the_post(); ?> <h2 class=”subpagetitle”> <a href=”https://wordpress.stackexchange.com/questions/55118/<?php the_permalink(); ?>” rel=”bookmark” title=”<?php the_title(); ?>”> <?php the_title(); ?> </a> </h2> <?php endwhile; // Reset Post Data wp_reset_postdata();

What is the right way to code links for WordPress pages?

For general links use home_url(). <a href=”https://wordpress.stackexchange.com/questions/55146/<?php echo esc_url( home_url(“/path/to/link’ ) );?>”>Anchor</a> To link to theme assets like images etc use get_stylesheet_directory_uri(). <img src=”https://wordpress.stackexchange.com/questions/55146/<?php echo get_stylesheet_directory_uri(); ?>/images/your_image.png” /> You could just as easily use relative links for navigation but I would stick with home_url() for consistency.

Show min and max taxonomy values

Not sure but try this: function get_years ($taxonomies, $args){ $output = array(); $hlterms = get_terms($taxonomies, $args); foreach($hlterms as $term){ $term_taxonomy = $term->year; array_push($output, $term->name); } return $output; } $taxonomies = array (‘year’); $args = array (‘hide_empty’=>true); $year = get_years($taxonomies, $args); echo min($year);

when does output of get_user_count turns into an array?

Via: http://lists.automattic.com/pipermail/wp-hackers/2012-June/043295.html http://wordpress.org/support/topic/illegal-string-offset-total_users?replies=14#post-2893756 https://core.trac.wordpress.org/ticket/20966 I find: Normally it would return an array from the cache Meaning the return value of get_user_count() is different than in the php doc above it But… if the cache does not contain it, it will return an integer leading (in my case) to an warning (requesting an array value from … Read more