Add class to every other posts using get_posts

A simple solution would be to add an alternating class to every other post in the list. In particular, (in your style.css) style the list elements <li> in one particular way, and then over-ride that style for list elements of a particular class <li class=”my-alternate-class”>. The class my-alternate-cass will applied to every other list element: … Read more

WordPress doesn’t load HTML

I changed the way I went about this and did this to solve it: $page = get_page( $menu->object_id ); $output .= apply_filters( ‘the_content’, $page->post_content ); My information now shows up correctly.

Customize Buddypress adminbar [closed]

First, you may want to consider using the WP toolbar (which features full BP integration), because the BP BuddyBar will not continue to be supported in future versions of BP. (It will probably still work, but it won’t be actively upgraded.) Flip the Toolbar on by putting define( ‘BP_USE_WP_ADMIN_BAR’, true ); into your wp-config.php file. … Read more

PHP time function ($today) for GMT +1

Time is one of the things in environment WordPress normalizes to GMT, so all native PHP function give that in WordPress context. To get time in timezone, set in WordPress settings, try date_i18n() instead.

CSS images don’t show up with bloginfo

If your style.css is in /wp-content/themes/themedirectory, and your image is at /wp-content/themes/themedirectory/images/image.jpg, then your css will be this: background-image: url(“images/image.jpg”); You can’t use php in a css file, it will not parse unless included via php (instead of with <link>).

how to insert content into my taxonomy

You’re using tax_input incorrectly. You’re not literally supposed to say taxonomy_name, you’re supposed to enter the name of your custom taxonomy. See https://codex.wordpress.org/Function_Reference/wp_insert_post. So, assuming your taxonomy is called ‘ninja_turtles’ and you are tagging your post with ‘donatello’ and ‘michelangelo’: // Create post object $my_post = array( ‘post_title’ => ‘My post’, ‘post_content’ => ‘This is … Read more

WordPress: Displaying all the post tags from within a specific taxonomy’s term

http://wordpress.org/support/topic/get-tags-specific-to-category $category_tags = $wpdb->get_results(” SELECT DISTINCT terms2.term_id as tag_ID, terms2.name as tag_name, t2.count as posts_with_tag FROM $wpdb->posts as p1 LEFT JOIN $wpdb->term_relationships as r1 ON p1.ID = r1.object_ID LEFT JOIN $wpdb->term_taxonomy as t1 ON r1.term_taxonomy_id = t1.term_taxonomy_id LEFT JOIN $wpdb->terms as terms1 ON t1.term_id = terms1.term_id, $wpdb->posts as p2 LEFT JOIN $wpdb->term_relationships as r2 ON … Read more