Get posts from all categories wordpress -
How to get all the posts from a category I tried this code, it is not displaying any output. Is this correct or is there any improvement here? Thank you. Include below: - ('wp-config.php'); Global $ wp_query; $ Args = ('category = news and post_on_page = -1'); $ Myposts = get_posts ($ Args); Forex Currency ($ myposts $ as post): setup_postdata ($ post); $ Result = array ("id" = & gt; $ args ['id'], "type" = $ args ['post_type'], "url" = & gt; $ args ['guid']) ; Endforeach; Wp_reset_postdata (); Print ($ result); Try
$ global Wp_query; $ Args = ('category = news and post_on_page = -1'); $ Myposts = get_posts ($ Args); Forex Currency ($ myposts $ as post): setup_postdata ($ post); $ Result [] = array ("id" => gtc: $ post-> ID, // $$$ "type" = & gt; $ post- & gt; post_type, "url" = & gt; $ Post- & gt; GUID); Endforeach; Wp_reset_postdata (); Print_r ($ result);
Comments
Post a Comment