I have a sidebar which might have any number of widgets. I can count the number of widgets that exist in the sidebar. How do I display randomly only one of the widgets in my sidebar at each page load?  Use: We have specials which we display as widgets, but we only want to display one widget's content at a time in the footer of the site.  re: the count code  &lt;?php $the_sidebars = wp_get_sidebars_widgets(); echo count( $the_sidebars['center-footer'] ); ?&gt;   re: generating a random widget instance  &lt;?php echo rand(1, count( $the_sidebars['center-footer'] )); ?&gt;
122953
My pages have a sidebar with too many widgets, and it looks bad when the content is short and the sidebar is too long.  I want to randomize the widgets I'm showing in the sidebar. Meaning I will add all the potential widgets to the sidebar, and it will randomly only display a few.  I would also like some control over this, for example to have a few widgets always appear, and only the rest randomized.  I tried finding relevant plugins, but the only ones I found just randomized images or posts.. never different types of widgets.
52840
I have another database which stores post's IDs and I want do display them using WP_query to use the WP default pagination. I'm using orderby => none to preserve the original order, but the result reorders them by IDs.  $ids = array (60, 23, 78, 46, 105, 130)  $args = array (     'posts_per_page' =&gt; -1,     'post__in' =&gt; $ids,     'orderby' =&gt; 'none' );  $query = new WP_Query ( $args );  while ( have_posts() ) : the_post();     echo '&lt;li&gt;';     the_title();     echo '&lt;/li&gt;'; endwhile;   Could anyone help me?  Thanks, Romulo De Lazzari
31099
In the Admin Panel, is there a way to hook into the page creation and increment Page Order number of each page or to be equal to the number of pages. Right now the default is 0 and when I make a new page i would much rather have it at the bottom of my list than the top.
118510
Let's say I have nested shortcode where the outmost shortcode is just HTML but the inner one is the one who displays the data.  [outer_shortcode][inner_code url="#" title="Hello"][/outer_shortcode]   In this case, the count of inner items is one. In the following one:  [outer_shortcode][inner_code url="#" title="Hello"][inner_code url="#2" title="Hello2"][/outer_shortcode]   The inner count is two.  How can I determine this on the functions that I work with?  I currently have (outer shortcode that calls the inner):  return '&lt;section id="recipes"&gt;&lt;nav&gt;&lt;ul&gt;'.do_shortcode($content).'&lt;/ul&gt;&lt;/nav&gt;&lt;/section&gt;';   And as inner:          $the_stuff .= '&lt;li&gt;';              $the_stuff .= '&lt;a href="' .$url. '" rel="external"&gt;'.$title.'&lt;/a&gt;';         $the_stuff .= '&lt;/li&gt;';          return $the_stuff;   That's what I want. To count the list items. How can I accomplish this?
54899
I'm trying to get my news page to display content from one category only (number 3) but I cant seem to get it to work. Instead of just displaying posts from category 3 it displays posts from all category's.  Here is my code:  &lt;?php get_header(); ?&gt;              &lt;div class="content news_page"&gt;                         &lt;h1&gt;Latest News&lt;/h1&gt;                              &lt;?php $args = array(                             'post_type' =&gt; 'post' ,                             'orderby' =&gt; 'date' ,                             'order' =&gt; 'DESC' ,                             'posts_per_page' =&gt; 6,                             'category'         =&gt; '3',                             'paged' =&gt; get_query_var('paged'),                             'post_parent' =&gt; $parent                        ); ?&gt;                        &lt;?php query_posts($args); ?&gt;                            &lt;?php if ( have_posts() ) : ?&gt;                             &lt;?php while ( have_posts() ) : the_post(); ?&gt;                                  &lt;div class="large-4 medium-4 small-12 columns"&gt;                                     &lt;div class="latest_news_cont"&gt;                                     &lt;a href="&lt;?php the_permalink() ?&gt;"&gt;&lt;?php the_post_thumbnail(); ?&gt;&lt;/a&gt;                                      &lt;a href="&lt;?php the_permalink() ?&gt;"&gt;&lt;h5&gt;&lt;?php the_title(); ?&gt;&lt;/h5&gt;&lt;/a&gt;                                     &lt;?php the_excerpt(); ?&gt;                                     &lt;p style="text-align:center;"&gt;&lt;a href="&lt;?php the_permalink() ?&gt;" class="readmore_news"&gt;Read more&lt;/a&gt;&lt;/p&gt; &lt;br&gt; &lt;div class="clear"&gt;&lt;/div&gt;                                        &lt;/div&gt;                                     &lt;/div&gt;                              &lt;?php endwhile; ?&gt;                         &lt;?php endif; ?&gt;   &lt;div class="clear"&gt;&lt;/div&gt;              &lt;/div&gt;&lt;!--end of content--&gt;    &lt;div class="clear"&gt;&lt;/div&gt;  &lt;?php get_footer(); ?&gt;
92762
I have 1000 images. How can i make wordpress to generate thumb only when needed. For example home slider will only use 10 images i dont want the other 1000 images have that thumbnail generated as its a waste of space and resources.  There is a way to fire add_image_size only when needed ?  Thanks  UPDATE As you mention is not really add_image_size what it needs to be fired. What it would be great is to fire the image resize when i use the_post_thumbnail('slider-thumb'); Maybe this slowdown the first view of the image but that view is usually generated by me when i actually review the post so i dont care.  So between my posts, slider, blog thumbnauls, portfolio thumbnails etc i got 1000 images and i want just 10 images to be resized for the slider i see a lot of wasted resources to generate the thumbnail size for the other 990 images.  Hope its clear now, sorry for my english
119674
I want 3 post with one loop iteration, so I'm using the_post() to achieve this: (html removed)  &lt;?php while ( have_posts() ) : the_post();      the_title();     the_post();     the_title();     the_post();     the_title();  endwhile; ?&gt;   The problem starts, if number of posts is not divisible by 3. For example, if I have 5 posts, than this loop will still try to display 6 of them, generating empty html. How can I work it out? Or maybe I'm trying to achieve this functionality the wrong way?  @edit: Here is HTML I wanna output to clarify my question:  &lt;div class="row"&gt; &lt;div class="span3"&gt;     &lt;h2&gt;Title&lt;/h2&gt;     &lt;p&gt;Content&lt;/p&gt; &lt;/div&gt; &lt;div class="span3"&gt;     &lt;h2&gt;Title&lt;/h2&gt;     &lt;p&gt;Content&lt;/p&gt; &lt;/div&gt; &lt;div class="span3"&gt;     &lt;h2&gt;Title&lt;/h2&gt;     &lt;p&gt;Content&lt;/p&gt; &lt;/div&gt;  &lt;/div&gt;   &lt;div class="row"&gt; &lt;div class="span3"&gt;     &lt;h2&gt;Title&lt;/h2&gt;     &lt;p&gt;Content&lt;/p&gt; &lt;/div&gt; &lt;div class="span3"&gt;     &lt;h2&gt;Title&lt;/h2&gt;     &lt;p&gt;Content&lt;/p&gt; &lt;/div&gt; &lt;div class="span3"&gt;     &lt;h2&gt;Title&lt;/h2&gt;     &lt;p&gt;Content&lt;/p&gt; &lt;/div&gt; &lt;/div&gt;   So I want to surround every 3 posts with .row.
102957
When wordpress sidebar outputs any particular registered sidebar it loop through all widgets that assigned through it and outputs it (i guess). Is is possible to hook into the loop and add some content, say I want to add a ad code every three widgets.  What I have tried? Unable to find any leads. Tried to search on wordpress source code but not sure what to search. searching widget or widget loop doesn't help.
105378
Use Case:  What i want is a list of records, and allow this user to choose 2 of those records, then click a button to go to a new VF page, if the user selects more than 2, i want him to get a notification of some kind saying you need to select 2 records, I do not want the page refeshed though.  Strategy:  I'm creating a wrapper class for the records like this:  and i have that part going by creating a custonm controller... I need the notification part working.   Problem:  I don't know how to call methods from the customController in javascript Also, i do not want to refresh the entire page. I just want them to go back to where they were. I was thinking a pop-up notification but I'm flexible..
83216
I'm a newbie in WordPress. I'm trying to understand how it generates the XHTML pages. I guess it's the function of do_action( 'hook-name' ) , but I'm stuck with the understanding of the instruction isset( $wp_filter['all] ) when reading the function do_action because I don't understand what is the meaning of the word all.  Is it a PHP feature or a WordPress one?
100043
I have a loop within a loop. I figured out how to show all or X number of custom posts after Y number of normal posts. I also figured out how to show 1 custom post after every Y normal posts. How do I show X custom posts after EVERY Y number of normal posts.  In simple terms. How do I show 2 book (custom post type) posts after every 4 blog posts? How does one fetch more than 1 post at a time from the loop?  this is the logic of the x custom posts after y normal posts. how do i get x custom posts after EVERY y normal posts?  main query // normal query $k=0 // setting iterator while have posts, the post  ---post markup---   if($k == 4 or $k % 4 == 0) { // whether after x number or after every x number second query // using WP_Query while second query has posts, the posts  ---custom post type markup // I NEED TO SHOW MORE THAN ONE HERE IF IT IS AFTER EVERY X blogposts  endwhile; //second query ends  }  $k++; endwhile // main query
109583
I want to render many(about 1000) components and I am displaying them through aura:iteration in another aura:iteration. This is causing me performance issues. I want to display only 10 records at an instance, and on scroll of mouse, load next 10 and so on...It should be like the way feed is loaded on a FB page or chatter. Any ideas how can this be implemented?     markup:   &lt;aura:iteration var="outerListElement" items="{!v.listOfLists}"&gt;    &lt;tr&gt;       &lt;aura:iteration var="singleEntry" items="{outerList"&gt;        &lt;td &gt;            &lt;div class="slds-truncate"&gt;                &lt;c:newComponent singleEntry="{!singleEntry}" outerListElement="{!outerListElement}" attr1="{!v.attr1OfParent}"&gt;            &lt;/div&gt;         &lt;/td&gt;       &lt;/aura:iteration&gt;    &lt;/tr&gt; &lt;/aura:iteration&gt;
70348
I have re-worded this to make more sense.  Ok, I have a plugin that uses a remote service that check for updates, much like default WordPress plugins, in this case it just checks an XML file.  I want to show a menu bubble like this  when an update is available.  It can show just a "1" or text like "alert", it doesn't matter.  Since my plugin uses an options page (using add_options_page) the plugin settings show up under the default "Settings" submenu.  I think I need to add the following CSS to get the bubble to show up,   &lt;span class='update-plugins count-1' title='title'&gt;&lt;span class='update-count'&gt;1&lt;/span&gt;&lt;/span&gt;   and tie into the global $submenu. The problem is I cannot use a hard-coded array value for the menu since each site will have different values.  So I cannot use $submenu[80][10] .= &lt;span class='update-plugins count-1' title='title'&gt;&lt;span class='update-count'&gt;1&lt;/span&gt;&lt;/span&gt;  How can I find my plugins submenu value, do I have to loop through the array and match the string values?  Also even when I hard-coded the values I could not get the bubble to show up.  //adding plugin to menu add_action('admin_menu', 'sec_plugin_checker');  function sec_plugin_checker() {   add_options_page(' Plugin Checker', 'Plugin Check', 'activate_plugins',    'sec_plugin_check', 'sec_checker');   // the conditional where I want the bubble to appear  if (!empty($matches)){      echo "Match found !&lt;br /&gt;";      global $submenu;     foreach( $submenu as $item ) {      $item[41][20] = sprintf( __( 'Updates %s', 'sec_plugin_checker' ),                   "&lt;span class='update-plugins count-1' title='title'&gt;                  &lt;span class='update-count'&gt;1&lt;/span&gt;&lt;/span&gt;");           }   }   and here is what a var_dump($submenu); looks like,   ["options-general.php"]=&gt; array(9){ ...  [41]=&gt;     array(4) {       [0]=&gt;       string(20) "Plugin Check"       [1]=&gt;       string(16) "activate_plugins"       [2]=&gt;       string(21) "sec_plugin_check"       [3]=&gt;       string(23) " Plugin Checker"       ...        }
65214
I would like to display the number of nodes in a particular view OUTSIDE OF THAT VIEW. For example, on the home page (page--front.tpl.php) I want to insert a simple php echo statement that pulls the number of nodes in "View X", and another php echo statement that pulls the number of nodes from "View Y", etc.  function theme_get_node_count($content_type) {      $query = "SELECT COUNT(*) amount FROM {node} n ".               "WHERE n.type = :type";      $result = db_query($query, array(':type' =&gt; $content_type))-&gt;fetch();      return $result-&gt;amount; }   The previous code does not work because I am not counting a content type. Is there a $view variable I can plugin into this function to achieve the same results?  Thanks
76690
On the search results page (search.php) I would like to perform an additional WP_Query to keep a specific order of search result types e.g. search results from authors should always be shown before the other results -  The first few pages should hold the author results, the other results should be shown on all the following pages only (not mixed on each page).  global $wp_query; //holds the results of the initial search query  $authorposts = $wp_query-&gt;posts;     $query = new WP_Query( 'year=2012&amp;monthnum=12&amp;day=12' ); $otherposts = $query-&gt;posts;  $wp_query-&gt;posts = array_merge( $authorposts, $otherposts  ); $wp_query-&gt;post_count = count( $wp_query-&gt;posts );  if ( have_posts() ) : while ( have_posts() ) : the_post(); ?&gt;   //show results loop...   The problems appear with the behaviour of pagination - while the $authorposts seem to paginate correctly i.e. correct page numbers for author posts and pagination works as only those where existent. But the $otherposts on the other hand are shown at the bottom of each page, right under the author posts. And they are the same on every page! Also the page count reflects the count of the first query only.  I have also tried to merge with the plus operator:  $wp_query-&gt;posts = $authorposts + $otherposts;   but in this scenario the $otherposts don't show up at all and the page count stays the same (page count for author posts).  All the examples with similar goals using two separate queries I've seen looked quite the same -  So I'm wondering if the my way of extending the original search query results with that additional WP_Query is sufficient or if I'm missing some $wp_query fields to be populated (correctly)? What's the correct way doing this?  Update: It should be noted that I'm using the WP-PageNavi plugin to paginate but this should not be relevant in the first place as the first page is already rendered wrong. And it's also initialized with the query object: wp_pagenavi( array( 'query' =&gt; $wp_query ));
118628
Is it possible to include or exclude specific named widgets that are assigned to a named dynamic_sidebar call?  For example, if I've registered a sidebar named "my_sidebar" and the user had placed a "Links" widget into it, I want to be able to include or exclude it based on a custom setting in my theme options panel.  Is this possible?  Any insights much appreciated.
42694
I'd like to show 20 posts on my custom tax template, using this filter:  function customize_customtaxonomy_archive_display ( $query ) {     if ( ( $query-&gt;is_main_query()) &amp;&amp; ( is_tax() ) ){         $query-&gt;set( 'posts_per_page', '20' );         $query-&gt;set( 'number_posts', '20' );         $query-&gt;set( 'orderby', 'rand' );         return;      } }  //Hook the function  add_action( 'pre_get_posts', 'customize_customtaxonomy_archive_display' );   If I set it to 2, two posts are shown. If I set it to 20, 12 posts are shown. There are never more than 12 posts displayed, although 34 are published.  What could be the issue?