montytx Posted February 20, 2009 Share Posted February 20, 2009 Hi All, Im new here and not much of a coder so I am hoping someone can help me figure out a simple problem. I have a wordpress site that I want to control what category shows up on the front page. The theme is custom so standard wordpress code is not being used. The code that I think controls this is: <?php if (Themehave_random_posts()) : ?> <?php while (Themehave_random_posts()) : $theme_queryRandom->the_post(); if(!@in_array(get_the_ID(), $showedPosts)){?> In the functions.php I have this code: function Themehave_random_posts(){ global $wp_query, $shortname, $theme_queryRandom, $wpdb, $cx, $showedPosts, $ids; if(!$theme_queryRandom){ $show = (int)get_settings($shortname."_randomCategoryPosts"); if(!in_array($show, $ids)) $ids[] = $show; $theme_queryRandom = new WP_Query('category_name='.get_cat_name($show).'&orderby=rand&showposts=1'); } $aux = $theme_queryRandom->have_posts(); if(get_the_ID()) $showedPosts[] = get_the_ID(); return $aux; } Any help is greatly appreciated. Thanks ! Quote Link to comment https://forums.phpfreaks.com/topic/146122-coding-question-in-wordpress/ Share on other sites More sharing options...
montytx Posted February 23, 2009 Author Share Posted February 23, 2009 No one? Quote Link to comment https://forums.phpfreaks.com/topic/146122-coding-question-in-wordpress/#findComment-768834 Share on other sites More sharing options...
montytx Posted March 3, 2009 Author Share Posted March 3, 2009 I would have thought this was a pretty simple problem. I guess not... ??? Quote Link to comment https://forums.phpfreaks.com/topic/146122-coding-question-in-wordpress/#findComment-775871 Share on other sites More sharing options...
alphanumetrix Posted March 4, 2009 Share Posted March 4, 2009 no... it's not necessarily complicated, but it's not so easy either. at least it is for me, because i haven't use wordpress. i don't know how this works entirely, but you should try this: function Themehave_random_posts(){ global $wp_query, $shortname, $theme_queryRandom, $wpdb, $cx, $showedPosts, $ids; if(!$theme_queryRandom){ $show = (int)get_settings($shortname."_randomCategoryPosts"); if(!in_array($show, $ids)) $ids[] = $show; $catiwant = 'my category'; // put your category in the apostraphies... $theme_queryRandom = new WP_Query('category_name='.$catiwant.'&orderby=rand&showposts=1'); } $aux = $theme_queryRandom->have_posts(); if(get_the_ID()) $showedPosts[] = get_the_ID(); return $aux; } Quote Link to comment https://forums.phpfreaks.com/topic/146122-coding-question-in-wordpress/#findComment-776792 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.