How to target the default Recent Posts and Recent Comments widgets with pre_get_posts?

pre_get_posts is executed before each and every query. Your $query->is_main_query() is making this code change the query only for the Main query. So, if you’re in an archive page, you’re modifying only the archive posts, and not any of the others queries (widgets, menus, etc). But be aware, that code you added there will change … Read more

How to get a category in a list item class

The first issue I’m seeing is that you’re trying to use the_category as a class. This won’t work as this function is intended to output the links to the categories assigned to that post. So it’s putting the href inside your class. You can debug and see how it works by removing your li and … Read more

Compile two queries to one set of results?

That would be nice if you query all three post_types at the same time, using one query, and then manipulating it using php. Consider this query: $args = array( ‘post_type’ => array( ‘pt1’, ‘pt2’, ‘pt3’ ), ‘meta_key’ => BUMP!!!! ); You can not use an array of meta_keys. So, I think the only way is … Read more

Generate a tabbed submenu — from taxonomy term or submenu item — with sample content

I ended up solving this problem with Ubermenu. What I wanted to write was complex enough that it made more sense to get a tested, commercial plugin that had the features I need. MaxMegaMenu didn’t do tabbed content but Ubermenu does. I’m able to construct menus like this: Taxonomy1 [Tabs] [DynamicTerms] [Dynamic Posts] Taxonomy2 [Tabs] … Read more

Order terms inside a select dropdown

I was working on someone else WP installation so I can get the info of WP Database to show Products information in a side-page. I’ve noticed that they have a plugin installed (Taxonomy order) that always return the terms posts in the same orden. Sorry for the confusion!

How to count data records in wordpress which have same meta_value in wp_postmeta table?

<?php global $wpdb; $table_name = $wpdb->prefix . “postmeta”; $login_name = sanitize_user( $_POST[‘parent_id’] ); $prepare = $wpdb->prepare( “SELECT COUNT(*) FROM $table_name WHERE meta_value=”Purva” AND meta_key = ‘parent_id’ “, $login_name ); $myrows = $wpdb->get_results( $prepare ); echo ‘<pre>’ . print_r( $myrows, true ) . ‘</pre>’; ?> I tried this and get values but still something missing…

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