I need to get an array from the wordpress database

Is this what you are asking for? Use it after the code you posted to create posts in loop and use thier ids to update meta fields. Replace “post_type” with your custom post type. foreach ($markers as $marker){ $post_id = wp_insert_post(array( “post_title” => “something”, “post_type” => “your-type”, “post_status” => “publish”, //by default they are drafts … Read more

Getting id of poll from WP database

The first problem I spotted is that you aren’t setting $latest_pollid but you are nonetheless trying to use that as the poll id. You should have something like: $latest_pollid = polls_latest_id(); before that line in order to set the value. There are big problems with what you are doing though. Hooking to after_setup_theme means that … Read more

Create WP_Query to search for posts by their categories or their parent/child categories

Use get_categories first to get all the post categories to use in the form, then loop through them to display a multicheck input… function hierarchical_category_inputs ($cat, $indent) { $cats = get_categories(‘hide_empty=false&orderby=name&order=ASC&parent=”.$cat); $indent++; if ($cats) { foreach ($cats as $cat) { echo “<input type=”checkbox’ name=”cat-“.$cat->term_id.”””; echo ” style=”margin-left: “.($indent*10).”px;”> “.$cat->name.”<br>”; hierarchical_category_inputs($cat->term_id, $indent); } } } echo … Read more

Delete transients in website

Transient are not always deleted when they expire, and that makes them unpredictable and sometimes a pain. Whenever I work with transients, I add some kind of functionality to delete the transients when something happens, like I delete transients when publishing posts or updating them if the transient was meant to keep data related to … Read more