get_posts by id not working

I have just found an alternative solution: global $post; $current_post = $post->ID; $array=range(1,$current_post); $args = array( “numberposts’ => 5, ‘offset’ => 0, ‘category’ => $category->term_id, ‘orderby’ => ‘ID’, ‘order’ => ‘DESC’, ‘exclude’ => $current_post, ‘post_type’ => ‘post’, ‘post_status’ => ‘publish’, ‘suppress_filters’ => true, ‘post__in’ => $array ); $posts = get_posts($args); I’m not sure why the … Read more

Making posts permalinks consistent numbers

I don’t really have the time or will to write and debug the code to make this work, but I can point you down a path to how you might make this work. A word of warning: it’s certainly not simple. You have to save the current number somewhere so you can retrieve and increment … Read more

Check is category parent with ids from the childs – get_term_children

Sry, here is my answer: Here is first the output for listing the category in checkbox: Walker for the Category Output class Adv_Multicheck_Walker_Category extends Walker { var $tree_type=”category”; var $db_fields = array (‘parent’ => ‘parent’, ‘id’ => ‘term_id’); function start_lvl($output, $depth, $args) { if ( ‘list’ != $args[‘style’] ) return $output; $indent = str_repeat(“\t”, $depth); … Read more

Get a post’s ID

If you’re on a singular page, sometime after init and all the query variables have all ben set up you can use get_queried_object_id or get_queried_object. <?php if (is_singular()) { $post_id = get_queried_object_id(); // or get the whole object $post = get_queried_object(); // or do the first one differently $post_id = get_queried_object()->ID; } You can also … Read more

get post by nav id

I think you need to loop the $menu_items because the function, according to the Codex, returns a array. Remplace echo $menu_items->ID; with foreach ( $menu_items as $menu_item ) { echo $menu_item->ID; } I need to check the array exactly, but if you need to compare a post ID to a menu item, you will need … Read more

Categories id Tags

get page id’s – not get pages?

Use the parameter ‘fields’: $pages = get_posts( array( ‘post_type’ => ‘page’, ‘meta_key’ => ‘_wp_page_template’, ‘meta_value’ => ‘product.php’, ‘fields’ => ‘ids’ ) ); Not tested, but it should fetch just the IDs.

Categories id Tags

Widget to show posts in the sidebar basing on its IDs

Try to replace ‘post__in’ => array($instance[‘postsToShow’]), with ‘post__in’ => explode(“,”, $instance[‘postsToShow’]), to feed the post__in with an array. Your current array looks like array(“123,456,789”) but should be like array(“123”, “456”, “789”)

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