Optimize apache for WP use

Greetings, I have a WP site with over than 150k pageviews /day. It's running on a Intel Core i5 CPU 760 @ 2.80GHz, with Centos and 4 GB of RAM. The problem is WP consumes too much RAM and after a while serve gets overloaded and RAM runs out. I've tried many Apache tweeks but nothing seems to work. After I restart Apache site will run smoothly but after an hour or two it will get overloaded again. Do any of you guys have any tip that will help me? BTW, I'm using WP-Super Cache. **UPDATE: Aditional info** Here's my list of plugins:   * Akismet   * Contact Form 7   * Domain Mirror   * Faster Image Insert   * IntenseDebate   * Role Manager   * SexyBookmarks   * Smart Youtube   * Star Rating for Reviews   * Thumbnail For Excerpts   * WP-Polls   * WP-SWFObject   * WP Super Cache As for the tweeks, I've tried some tips from here My settings are:                <IfModule prefork.c>        StartServers       8       MinSpareServers    5        MaxSpareServers   20        ServerLimit      256        MaxClients       200        MaxRequestsPerChild  1000      </IfModule>                         <IfModule worker.c>        StartServers       2        MaxClients         150       MinSpareThreads     25        MaxSpareThreads    75       ThreadsPerChild     25       MaxRequestsPerChild  1000      </IfModule>                          Timeout 120 KeepAlive On      MaxKeepAliveRequests 100      KeepAliveTimeout 2      Also here's my my.cnf               [mysqld]     set-variable=local-infile=0     datadir=/var/lib/mysql     socket=/var/lib/mysql/mysql.sock     user=mysql     # Default to using old password format for compatibility with mysql 3.x     # clients (those using the mysqlclient10 compatibility package).     old_passwords=1          # Disabling symbolic-links is recommended to prevent assorted security risks;     # to do so, uncomment this line:     # symbolic-links=0          [mysqld_safe]     log-error=/var/log/mysqld.log     pid-file=/var/run/mysqld/mysqld.pid      **UPDATE** Here's my current memory usage               ps -ylC httpd --sort:rss          S   UID   PID  PPID  C PRI  NI   RSS    SZ WCHAN  TTY          TIME CMD     S   504  8446  8444  0  78   0  7884 59507 554050 ?        00:00:00 httpd     S   504 29164  8444  0  78   0 13380 87043 -      ?        00:00:00 httpd     S   504 29268  8444  0  75   0 13396 87043 429493 ?        00:00:00 httpd     S   504 29294  8444  0  75   0 13396 87043 -      ?        00:00:00 httpd     S   504 29255  8444  0  75   0 13400 87043 -      ?        00:00:00 httpd     S   504 29269  8444  0  76   0 13400 87043 387946 ?        00:00:00 httpd     S   504 29256  8444  0  75   0 13404 87043 -      ?        00:00:00 httpd     S   504 29265  8444  0  75   0 13404 87043 -      ?        00:00:00 httpd     S   504 29288  8444  0  75   0 13404 87043 429493 ?        00:00:00 httpd     S   504 28644  8444  0  75   0 13484 87043 -      ?        00:00:00 httpd     S   504 29293  8444  0  75   0 13484 87043 semtim ?        00:00:00 httpd     S   504 27280  8444  0  75   0 13496 87043 -      ?        00:00:00 httpd     S   504 28332  8444  0  75   0 13500 87043 -      ?        00:00:00 httpd     S   504 27762  8444  0  75   0 13504 87043 -      ?        00:00:00 httpd     S   504 28645  8444  0  75   0 13504 87043 -      ?        00:00:00 httpd     S   504 29242  8444  0  75   0 13508 87043 -      ?        00:00:00 httpd     S   504 28199  8444  0  75   0 13512 87043 429493 ?        00:00:00 httpd     S   504 28195  8444  0  75   0 13528 87043 -      ?        00:00:00 httpd     S   504 28197  8444  0  75   0 13528 87043 429493 ?        00:00:00 httpd     S   504 27245  8444  0  75   0 13536 87043 -      ?        00:00:00 httpd     S   504 28196  8444  0  75   0 13536 87043 -      ?        00:00:00 httpd     S   504 27756  8444  0  75   0 13540 87043 -      ?        00:00:00 httpd     S   504 27969  8444  0  75   0 13540 87043 -      ?        00:00:00 httpd     S   504 27074  8444  0  75   0 13544 87043 -      ?        00:00:00 httpd     S   504 27279  8444  0  75   0 13544 87043 -      ?        00:00:00 httpd     S   504 27926  8444  0  75   0 13548 87043 -      ?        00:00:00 httpd     S   504 28191  8444  0  75   0 13548 87043 semtim ?        00:00:00 httpd     S   504 28673  8444  0  75   0 13548 87043 -      ?        00:00:00 httpd     S   504 27089  8444  0  75   0 13552 87043 -      ?        00:00:00 httpd     S   504 27825  8444  0  75   0 13552 87043 -      ?        00:00:00 httpd     S   504 27974  8444  0  75   0 13552 87043 -      ?        00:00:00 httpd     S   504 28330  8444  0  75   0 13552 87043 -      ?        00:00:00 httpd     S   504 26051  8444  0  75   0 13556 87043 -      ?        00:00:00 httpd     S   504 28343  8444  0  75   0 13556 87043 -      ?        00:00:00 httpd     S   504 26822  8444  0  75   0 13560 87043 -      ?        00:00:00 httpd     S   504 27975  8444  0  75   0 13560 87043 -      ?        00:00:00 httpd     S   504 28662  8444  0  75   0 13560 87043 -      ?        00:00:00 httpd     S   504 24949  8444  0  75   0 13564 87043 -      ?        00:00:00 httpd     S   504 28639  8444  0  75   0 13564 87043 -      ?        00:00:00 httpd     S   504 24924  8444  0  75   0 13572 87043 -      ?        00:00:00 httpd     S   504 27826  8444  0  75   0 13572 87043 -      ?        00:00:00 httpd     S   504 28192  8444  0  75   0 13572 87043 -      ?        00:00:00 httpd     S   504 28683  8444  0  76   0 13572 87043 -      ?        00:00:00 httpd     S   504 19032  8444  0  75   0 13576 87043 -      ?        00:00:00 httpd     S   504 26832  8444  0  75   0 13576 87043 -      ?        00:00:00 httpd     S   504 28186  8444  0  75   0 13580 87043 -      ?        00:00:00 httpd     S   504 24940  8444  0  75   0 13584 87043 -      ?        00:00:00 httpd     S   504 27883  8444  0  75   0 13584 87043 -      ?        00:00:00 httpd     S   504 27962  8444  0  75   0 13588 87043 -      ?        00:00:00 httpd     S   504 28331  8444  0  75   0 13588 87043 -      ?        00:00:00 httpd     S   504 18521  8444  0  75   0 13592 87043 -      ?        00:00:00 httpd     S   504 24291  8444  0  75   0 13592 87043 -      ?        00:00:00 httpd     S   504 24307  8444  0  75   0 13592 87043 -      ?        00:00:00 httpd     S   504 26503  8444  0  75   0 13592 87043 -      ?        00:00:00 httpd     S   504 26510  8444  0  75   0 13592 87043 -      ?        00:00:00 httpd     S   504 27100  8444  0  75   0 13592 87043 -      ?        00:00:00 httpd     S   504 27248  8444  0  75   0 13592 87043 429493 ?        00:00:00 httpd     S   504 28344  8444  0  75   0 13592 87043 429493 ?        00:00:00 httpd     S   504 24952  8444  0  75   0 13596 87043 -      ?        00:00:00 httpd     S   504 26588  8444  0  75   0 13596 87043 -      ?        00:00:00 httpd     S   504 27065  8444  0  75   0 13596 87043 -      ?        00:00:00 httpd     S   504 27102  8444  0  75   0 13600 87043 -      ?        00:00:00 httpd     S   504 27104  8444  0  75   0 13600 87043 429493 ?        00:00:00 httpd     S   504 27474  8444  0  75   0 13600 87043 429493 ?        00:00:00 httpd     S   504 27763  8444  0  75   0 13600 87043 -      ?        00:00:00 httpd     S   504 23657  8444  0  75   0 13604 87043 -      ?        00:00:00 httpd     S   504 24311  8444  0  75   0 13604 87043 -      ?        00:00:00 httpd     S   504 24790  8444  0  75   0 13604 87043 -      ?        00:00:00 httpd     S   504 25731  8444  0  75   0 13604 87043 -      ?        00:00:00 httpd     S   504 27087  8444  0  75   0 13604 87043 -      ?        00:00:00 httpd     S   504 24473  8444  0  75   0 13608 87043 -      ?        00:00:00 httpd     S   504 27976  8444  0  75   0 13612 87043 -      ?        00:00:00 httpd     S   504 28163  8444  0  75   0 13620 87043 -      ?        00:00:00 httpd     S   504 29266  8444  0  75   0 14204 87043 -      ?        00:00:00 httpd     S   504 17701  8444  0  75   0 14392 87043 -      ?        00:00:00 httpd     S   504 27881  8444  0  75   0 14408 87043 -      ?        00:00:00 httpd     S   504 26593  8444  0  75   0 14412 87043 -      ?        00:00:00 httpd     S   504 27072  8444  0  76   0 14428 87043 -      ?        00:00:00 httpd     S   504 17704  8444  0  75   0 15028 87043 -      ?        00:00:00 httpd     S   504 28674  8444  0  75   0 17076 87299 -      ?        00:00:00 httpd     S   504 23649  8444  0  75   0 17180 87299 -      ?        00:00:00 httpd     S   504 21484  8444  0  75   0 17232 87299 429493 ?        00:00:00 httpd     S   504 24034  8444  0  75   0 17240 87299 -      ?        00:00:00 httpd     S   504 24941  8444  0  75   0 17248 87299 -      ?        00:00:00 httpd     S   504 27058  8444  0  75   0 17256 87299 -      ?        00:00:00 httpd     S   504 24766  8444  0  75   0 17272 87299 -      ?        00:00:00 httpd     S   504 28333  8444  0  75   0 17284 87299 semtim ?        00:00:00 httpd     S   504 20565  8444  0  75   0 17296 87299 semtim ?        00:00:00 httpd     S   504 25462  8444  0  75   0 17296 87299 -      ?        00:00:00 httpd     S   504 28201  8444  0  75   0 17296 87299 -      ?        00:00:00 httpd     S   504 28202  8444  0  75   0 17316 87299 -      ?        00:00:00 httpd     S   504 27968  8444  0  75   0 17328 87299 -      ?        00:00:00 httpd     S   504 27973  8444  0  75   0 17328 87299 -      ?        00:00:00 httpd     S   504 24091  8444  0  75   0 17336 87299 429493 ?        00:00:00 httpd     S   504 28329  8444  0  75   0 17344 87299 -      ?        00:00:00 httpd     S   504 27885  8444  0  75   0 17352 87299 -      ?        00:00:00 httpd     S   504 21556  8444  0  75   0 17356 87299 semtim ?        00:00:00 httpd     S   504 24121  8444  0  75   0 17356 87299 429493 ?        00:00:00 httpd     S   504 24929  8444  0  75   0 17356 87299 -      ?        00:00:00 httpd     S   504 27918  8444  0  75   0 17356 87299 -      ?        00:00:00 httpd     S   504 24778  8444  0  75   0 17360 87299 -      ?        00:00:00 httpd     S   504 27075  8444  0  75   0 17360 87299 -      ?        00:00:00 httpd     S   504 20603  8444  0  75   0 17364 87299 -      ?        00:00:00 httpd     S   504 24031  8444  0  75   0 17364 87299 429493 ?        00:00:00 httpd     S   504 24791  8444  0  75   0 17364 87299 -      ?        00:00:00 httpd     S   504 26509  8444  0  75   0 17364 87299 -      ?        00:00:00 httpd     S   504 27249  8444  0  75   0 17364 87299 -      ?        00:00:00 httpd     S   504 24148  8444  0  75   0 17372 87299 -      ?        00:00:00 httpd     S   504 24777  8444  0  75   0 17372 87299 -      ?        00:00:00 httpd     S   504 24472  8444  0  75   0 17392 87299 semtim ?        00:00:00 httpd     S   504 24789  8444  0  75   0 17432 87299 429493 ?        00:00:00 httpd     S   504 27066  8444  0  75   0 17432 87299 429493 ?        00:00:00 httpd     S   504 27106  8444  0  75   0 17452 87299 -      ?        00:00:00 httpd     S   504 26508  8444  0  75   0 17472 87299 -      ?        00:00:00 httpd     S   504 24168  8444  0  75   0 17488 87299 -      ?        00:00:00 httpd     S   504 22355  8444  0  75   0 17492 87299 -      ?        00:00:00 httpd     S   504 23656  8444  0  75   0 17844 87555 -      ?        00:00:00 httpd     S   504 27088  8444  0  75   0 17888 87555 -      ?        00:00:00 httpd     S   504 28198  8444  0  75   0 17900 87555 -      ?        00:00:00 httpd     S   504 26694  8444  0  75   0 17960 87555 -      ?        00:00:00 httpd     S     0  8444     1  0  78   0 20276 87043 -      ?        00:00:00 httpd     S   504 27271  8444  0  75   0 28796 90883 -      ?        00:00:00 httpd     S   504 19949  8444  0  75   0 28888 90883 -      ?        00:00:00 httpd     S   504 25736  8444  0  75   0 29840 91395 -      ?        00:00:00 httpd     S   504 27086  8444  0  75   0 29848 91395 -      ?        00:00:00 httpd     S   504 26606  8444  0  75   0 29856 91395 429493 ?        00:00:00 httpd     S   504 24159  8444  0  75   0 29876 91395 -      ?        00:00:00 httpd     S   504 26821  8444  0  75   0 29876 91395 -      ?        00:00:00 httpd     S   504 26815  8444  0  75   0 29932 91395 -      ?        00:00:00 httpd     S   504 27418  8444  0  75   0 29940 91395 -      ?        00:00:00 httpd     S   504 27426  8444  0  75   0 29944 91395 semtim ?        00:00:00 httpd     S   504 27468  8444  0  75   0 29948 91395 -      ?        00:00:00 httpd     S   504 26587  8444  0  75   0 29952 91395 -      ?        00:00:00 httpd     S   504 24486  8444  0  75   0 29956 91395 semtim ?        00:00:00 httpd     S   504 24951  8444  0  75   0 29956 91395 429493 ?        00:00:00 httpd     S   504 24180  8444  0  75   0 29960 91395 -      ?        00:00:00 httpd     S   504 24305  8444  0  75   0 29972 91395 -      ?        00:00:00 httpd     S   504 24467  8444  0  75   0 30008 91395 -      ?        00:00:00 httpd     S   504 26507  8444  0  75   0 30032 91395 semtim ?        00:00:00 httpd     S   504 24460  8444  0  75   0 30056 91651 -      ?        00:00:00 httpd     S   504 23669  8444  0  75   0 30076 91395 -      ?        00:00:00 httpd     S   504 26580  8444  0  75   0 30088 91651 -      ?        00:00:00 httpd     S   504 23112  8444  0  75   0 30172 91395 -      ?        00:00:00 httpd     S   504 26607  8444  0  75   0 30192 91395 -      ?        00:00:00 httpd     S   504 24772  8444  0  75   0 30212 91395 -      ?        00:00:00 httpd     S   504 24942  8444  0  75   0 30216 91395 -      ?        00:00:00 httpd     S   504 24167  8444  0  75   0 30220 91395 -      ?        00:00:00 httpd     S   504 26478  8444  0  75   0 30228 91395 -      ?        00:00:00 httpd     S   504 24184  8444  0  75   0 30260 91395 429493 ?        00:00:00 httpd     S   504 27425  8444  0  75   0 30292 91395 -      ?        00:00:00 httpd     S   504 22348  8444  0  75   0 30388 91651 -      ?        00:00:00 httpd     S   504 26605  8444  0  75   0 30396 91651 -      ?        00:00:00 httpd     S   504 22678  8444  0  75   0 30420 91395 -      ?        00:00:00 httpd     S   504 24489  8444  0  75   0 30452 91395 153384 ?        00:00:00 httpd     S   504 24296  8444  0  75   0 30480 91395 -      ?        00:00:00 httpd     S   504 24095  8444  0  75   0 30600 91651 -      ?        00:00:00 httpd     S   504 23085  8444  0  75   0 30688 91651 -      ?        00:00:00 httpd     S   504 19586  8444  0  75   0 30768 91395 -      ?        00:00:00 httpd     S   504 24182  8444  0  75   0 30768 91395 -      ?        00:00:00 httpd     S   504 18511  8444  0  75   0 30820 91395 -      ?        00:00:00 httpd     S   504 26594  8444  0  75   0 30836 91395 -      ?        00:00:00 httpd     S   504 13358  8444  0  75   0 30856 91651 -      ?        00:00:00 httpd     S   504 17681  8444  0  75   0 30988 91395 -      ?        00:00:00 httpd     S   504 22336  8444  0  75   0 31016 91651 -      ?        00:00:00 httpd     S   504 15690  8444  0  75   0 31040 91395 -      ?        00:00:00 httpd     S   504 22718  8444  0  75   0 31072 91651 -      ?        00:00:00 httpd     S   504 19043  8444  0  75   0 31080 91395 -      ?        00:00:00 httpd     S   504 12815  8444  0  75   0 31108 91651 -      ?        00:00:00 httpd     S   504 23301  8444  0  75   0 31112 91395 -      ?        00:00:00 httpd     S   504 24183  8444  0  75   0 31164 91395 -      ?        00:00:00 httpd     S   504 22670  8444  0  75   0 31180 91395 -      ?        00:00:00 httpd     S   504 22327  8444  0  75   0 31216 91651 -      ?        00:00:00 httpd     S   504 21489  8444  0  75   0 31220 91395 -      ?        00:00:00 httpd     S   504 21474  8444  0  75   0 31284 91395 -      ?        00:00:00 httpd     S   504 21596  8444  0  75   0 31296 91651 -      ?        00:00:00 httpd     S   504 22690  8444  0  75   0 31448 91395 -      ?        00:00:00 httpd     S   504 26595  8444  0  75   0 31452 91651 429493 ?        00:00:00 httpd     S   504 20312  8444  0  75   0 31476 91651 429493 ?        00:00:00 httpd     S   504 24313  8444  0  75   0 31592 91397 -      ?        00:00:00 httpd     S   504 24179  8444  0  75   0 31696 91395 -      ?        00:00:00 httpd     S   504 22369  8444  0  76   0 31732 88329 -      ?        00:00:00 httpd     S   504 13373  8444  0  75   0 31768 91395 429493 ?        00:00:00 httpd     S   504 17667  8444  0  75   0 31960 91651 429493 ?        00:00:00 httpd     S   504 18517  8444  0  75   0 32012 91651 -      ?        00:00:00 httpd     S   504  7793  8444  0  75   0 32040 91651 -      ?        00:00:00 httpd     S   504 17658  8444  0  75   0 32116 91395 -      ?        00:00:00 httpd     S   504 27272  8444  0  75   0 32224 91395 -      ?        00:00:00 httpd     S   504 13901  8444  0  75   0 32784 91395 -      ?        00:00:00 httpd     S   504 15366  8444  0  75   0 33168 91651 -      ?        00:00:00 httpd     S   504 24577  8444  0  75   0 33256 88085 -      ?        00:00:00 httpd     S   504 14330  8444  0  75   0 34192 91651 -      ?        00:00:00 httpd     S   504 15155  8444  0  75   0 34296 91395 -      ?        00:00:00 httpd     S   504 16312  8444  0  75   0 34496 91395 -      ?        00:00:00 httpd     S   504 28194  8444  0  75   0 36996 88848 -      ?        00:00:00 httpd     S   504 24776  8444  0  75   0 43720 92169 429493 ?        00:00:00 httpd     S   504 20584  8444  0  75   0 44224 92169 -      ?        00:00:00 httpd     S   504 22331  8444  0  75   0 44636 91913 -      ?        00:00:00 httpd     S   504 24033  8444  0  75   0 45496 91664 -      ?        00:00:00 httpd     S   504 22375  8444  0  75   0 46320 91664 -      ?        00:00:00 httpd     S   504 22378  8444  0  75   0 50064 91664 -      ?        00:00:00 httpd     S   504 24481  8444  0  75   0 53836 93968 -      ?        00:00:00 httpd     S   504 22354  8444  0  75   0 62124 93962 -      ?        00:00:00 httpd      Doest that change what you would recommend me?


wp-custom-menu filter removes the current_page_item class

After adding wp-custom-menu-filter plugin - to hide some menu items for not- logged in users, the current_page_item class disappeared from my menu. `$item->classes` in the walker is an empty array, instead of usual `page- item-$id`, `current_page_item`. I've looked at the source, but it does not modify the classes array, so I don't know what's going on. Here is the relevant part of the code.               function wps_custom_nav_menu_items( $args ){         global $wpcmfp_settings;              $nav_item_db_id = $args[1]->ID;         $nav_menu = wp_get_object_terms( $nav_item_db_id, 'nav_menu' );         $menu_id = $nav_menu[0]->term_id;              // Get the class to exclude         if ( !is_user_logged_in() ) {             $exclusion_class = $wpcmfp_settings[ 'menu-' . $menu_id . '-loggedout' ];         }         else {             $exclusion_class = $wpcmfp_settings[ 'menu-' . $menu_id . '-loggedin' ];         }              $nav_items = wp_get_nav_menu_items( $menu_id );              // Cycle through all nav_items         foreach ( $nav_items as $nav_item ) {                     // Cycle through all classes             for ( $i=0; $i < count( $nav_item->classes ); $i++ ) {                 $exclude = false;                      // if nothing is there set to add                 if ( strlen ( $nav_item->classes[ $i ] ) < 1 ) {                     $exclude = false;                 }                 else                 {                        // if matches add to exclusion array & break loop                     if ( $nav_item->classes[ $i ] == $exclusion_class ) {                         $excluded_nav_items[] = $nav_item;                          $exclude = true;                         break;                     }                 }             }                  if ( $exclude != true )                 $modified_nav_items[] = $nav_item;              }              return $modified_nav_items;     }          add_filter( 'wp_nav_menu_objects', 'wps_custom_nav_menu_items' , 10 , 3);      I'm using custom page walker, I've tried using the default one with no effect, and the custom one works just fine without this plugin. Here is the code of the walker:               class My_Walker_Page extends Walker_Nav_Menu {            protected $_counter = 0;       protected $_itemsPerColumn = 1;            function start_lvl(&$output, $depth) {         $this->_counter = 0;              $output .= '<some html>';            }            function end_lvl(&$output, $depth) {         $output .= '<some html>';                 $this->_counter = 0;       }            function start_el(&$output, $page, $depth, $args, $current_page = null) {              $args = ( array ) $args;              if ($depth == 0) {           return parent::start_el ( $output, $page, $depth, $args, $current_page );         }              if ($depth == 1) {           extract ( $args, EXTR_SKIP );           $output .= '
url ) . '" title="' . esc_attr ( wp_strip_all_tags ( apply_filters ( 'the_title', $page->title, $page->ID ) ) ) . '">' . $link_before . apply_filters ( 'the_title', $page->title, $page->ID ) . $link_after . '';                if (! empty ( $page->description )) {             $output .= '' . $page->description . '';           }                $output .= '
';                $this->_counter ++;           if ($this->_counter % $this->_itemsPerColumn == 0) {             $output .= '

';           }              }       }            function end_el(&$output, $page, $depth) {         if ($depth == 0) {           return parent::end_el ( &$output, $page, $depth );         }       }            function display_element($element, &$children_elements, $max_depth, $depth = 0, $args, &$output) {              if (! $element)           return;              $id_field = $this->db_fields ['id'];         if ($depth == 0) {           $this->_itemsPerColumn = ceil ( count ( $children_elements [$element->$id_field] ) / 4 );         }              return parent::display_element ( $element, $children_elements, $max_depth, $depth, $args, $output );       }     }      I'm OK with going with another way to hide menu items for non-logged in users, instead of fixing the plugin, but since I've never used the `wp_nav_menu_objects` I really don't know what is going on.


Using call_user_func() within add_settings_section() within a Class

I am trying to `add_settings_section()` by supplying a callback with parameter as follows:               class warpress_progression_plugin {       function warpress_progression_plugin() {         $this->__construct();       }       function __construct() {         add_action('admin_init', array(&$this, 'plugin_admin_init'));       }       function plugin_admin_init() {         $rows = $this->get_options_structure();         for ($i = 0; $i < count($rows); $i++) {           add_settings_section('expansion_'.$row->expansion_id,'',call_user_func(array(&$this, 'display_expansion'), $row->expansion),'warpress_progression'); // PROBLEM SEEMS TO BE HERE         }       }       function display_expansion($expansion_name) {         echo "
" . $expansion_name . "
";       }     }      However, I'm getting the following error: > **Warning: call_user_func() [function.call-user-func]: First argument is > expected to be a valid callback** However, the echo of               "
" . $expansion_name . "
"      is occurring as I would have expected. What am I doing wrong here?


Set menu active state for custom posttype and category, given custom taxonomy term

How to set the menu active state for a custom posttype and category, given a custom taxonomy term? I have a custom taxonomy: region, a custom posttype: business, and use the categories taxonomy. My custom primary menu consists of the region terms. When I select a region, the corresponding menu item is highlighted OK. The region page shows a listing of relevant categories. Now, when I select a category on this page the corresponding menu item is not highlighted. In turn, the category page shows a listing of businesses. Also, when I click on a business, the corresponding menu-item is not highlighted. So, how to set the menu active state on a category page and on a business post, given a custom taxonomy term? I do have a session variable region available on these pages.


Rewrite permalinks for custom posttype and custom taxonomy

How to rewrite permalinks for a custom posttype and custom taxonomy? I have a custom taxonomy: region, and a custom posttype: business. Now, how to rewrite the permalink, so that   * for a category, the fixed "category" part is replaced with the custom taxonomy term: `/%region%/%category%/`   * for a business: `/%region%/%category%/%business%/` I'm stuck with this. However, I did manage to rewrite the permalink for a region to `/%region%/`:               add_action( 'init', 'region_init' );     function region_init() {       // set labels         $labels = array(         'name' => _x( 'Regions', 'taxonomy general name' ),         'singular_name' => _x( 'Region', 'taxonomy singular name' ),         'search_items' =>  __( 'Search Regions' ),         'popular_items' =>  __( 'Popular Regions' ),         'all_items' => __( 'All Regions' ),         'parent_item' => __( 'Parent Region' ),         'parent_item_colon' => __( 'Parent Region:' ),         'edit_item' => __( 'Edit Region' ),          'update_item' => __( 'Update Region' ),         'add_new_item' => __( 'Add New Region' ),         'new_item_name' => __( 'New Region Name' )       );       // create a new taxonomy       register_taxonomy(         'region',         'business',         array(           'labels' => $labels,           'label' => __('Region'),           'sort' => true,           'args' => array('orderby' => 'term_order'),           'show_in_nav_menus' => true,           'query_var' => true,           'rewrite' => array( 'slug' => '', 'with_front' => false )         )       );     }          add_action('init', 'my_rewrite');     function my_rewrite() {         global $wp_rewrite;         $wp_rewrite->add_permastruct('typename', 'typename/%year%/%postname%/', true, 1);         add_rewrite_rule('typename/([0-9]{4})/(.+)/?$', 'index.php?typename=$matches[2]', 'top');         $wp_rewrite->flush_rules(); // !!!     }


How can i change the order of comments?

I like to have the latest comment shown above. Just under the post. Now the oldest comment is shown. How can i change the order? With regards, Albert


Calling the widget id of a mult-instance widget from inside the widget?

I'm trying to output a unique widget ID inside my mult-instance widgets. So far the following hasn't worked. Is there a unique ID and how do I call it? Thanks.               function widget($args, $instance) {     // outputs the content of the widget         extract( $args );         $widget_id = $instance['widget_id'];         ?>     <?php echo $widget_id ; ?>     <?php     }      Thanks.


Controlling Taxonomy Category listings to hide and unhide specifics

I have a vertical menu using the superfish script that shows categories in a custom 'productcategory' taxonomy. This menu has multiple levels, and is hierarchical.At the bottom of each branch of the tree we have the end category which represents a range of products, which the client does **not** want to show in this menu. I am using this code to display it:               <ul class="frontcatlist sf-menu">     <?php         $a = array(             'title_li'  =>  '',             'taxonomy'  =>  'productcategory',             'depth'     =>  2         );         wp_list_categories( $a );     ?>     </ul>      This is what I currently have in terms of what is showing and what isnt. left being the main categories, and each line being 1 step down to its children: ![alt text](http://i.stack.imgur.com/0Mw70.jpg) Those in the red are the categories that are not shown in the menu, This is not what my client needs however. While I could produce a menu that fits the requirements using the native Wordpress 3 menus, that would require manual intervention, intervention that is undesirable, both from a usability perspective, and from the clients wishes. Since some main categories have subcategories that should be shown and some dont, the depth parameter will not suffice. Instead this is what I need, with the top level categories always showing: ![alt text](http://i.stack.imgur.com/TgUMB.jpg) Im not sure how to do this, and the only clue I have is a custom walker class to output custom html, during which I might be able to filter out the ones I dont want **( any categories with a parent that has no children)**. But I could not see any sufficient examples or articles on the subject, and I'd rather not loose the classes and markup wordpress provides If anybody has any thoughts, or knows of tutorials forum posts or articles of use, I'd much appreciate it =)


wp_list_pages sort order by custom nav menu order

Does anyone know of a way to create a sitemap by using wp_list_pages and have the order by the same orders a custom nav menu?


echo get_post_meta()

this is a silly question, but i dont know, can anyone help me out in this i want to `echo get_post_meta()` on a url, but i am getting parse error i am having a function, where in the between of url one field can be filled by the value of custom field here is the code `($doc->load('http://twitter.com/statuses/user_timeline/' . . '.rss'));` the space between `. .` there i want to echo the value of my get_post_meta value, but if i write something like this `($doc->load('http://twitter.com/statuses/user_timeline/' .echo get_post_meta() . '.rss'));` i know this step is wrong, then too i tried, i get parse error how can i echo it???


add a "list" into add meta box : problem

i found a code searching through stackexchange --> to create a "list" inside a meta box of a custom type, BUT, i don't see anything appearing in this meta box, except the input field (which comes from the example page from the CODEX : http://codex.wordpress.org/Function_Reference/add_meta_box), is it a problem with WP_QUERY inside a function? Can you please tell me what is the magic trick to fix this? in my callback function, i added this code :               function myplugin_inner_custom_box() {       // Use nonce for verification       wp_nonce_field( plugin_basename( __FILE__ ), 'myplugin_noncename' );            // The actual fields for data entry       echo '<label for="myplugin_new_field">';       _e("Description for this field", 'myplugin_textdomain' );       echo '</label> ';       echo '<input type="text" id="myplugin_new_field" name="myplugin_new_field"/>';                $s_query = new WP_Query( array(      'suppress_filters' => false,      'post_type' => 'movies'));     while($s_query->have_posts()):$s_query->the_post();              $sname = $post->post_title;         $s_output2 ='';         $s_output2 .= '<option value="'.$post->ID.'" >';         $s_output2 .= $post->post_title;         $s_output2 .= '</option>';         echo $s_output2;          endwhile ;     wp_reset_query();     }      But as i said, the "list" doesn't appear. Could you please help me?


How to increase the character limit for post name of 200?

I have post name in Thai which uses `UTF-8` character. Many of them encode into super long in ASCII e.g. วิธีการหลีกเลี่ยงข้อผิดพลาดทั้ง-8-ในชีวิตการแต่งงาน I've changed the type of "post_name" using phpMyAdmin to `VARCHAR(1000)` and collation to `utf8_unicode_ci`. However, in my WordPress backend editor, the above post name is still automatically cut to วิธีการหลีกเลี่ยงข้อผิ when I try to save the URL. There is this plugin that lift the character limit but it's in Thai which I can't read. Any ideas?


Is there any site where i can found good documentation of wp-ecommerce plugin?

**There is no good documentation in the plugin official site** I am trying to making a web shop in WordPress with wp-ecommerce pluign. But i don't find any good documentation in the web. Even the official site for the plugin is not helping. Do you know any site or good tutorial about the wp-ecommerce plugin? I will really appreciate if you can share your personal experience with me.


How to handle a shortcode function directly?

I was wondering how i can handle a shortcode function directly? At the moment i have created a shortcode which works OK. The shortcode function outputs a image. Now in functions.php i have another function which needs the output image. I am using the do_shortcode and it works.               $image = do_shortcode('[route_thumb id="'.$post_id.'"]') ;      but how can i call the function directly this one didn't work                $image = route_thumb_function($atts['id']=$post_id);


wp_dropdown_pages() returns empty string for post type anything other then page

`wp_dropdown_pages()` while using for any post type other then `page` returns empty string. Codex says post type can be passed as key also the function uses `get_pages()` which takes the `post_type` key. So, I don't see why it isn't working for me.                   $args = array(             'echo' => 1,             'name' => 'my_posts',             'post_type' => 'post',             'show_option_none' => 'any'         );         $select = wp_dropdown_pages($args);      Any idea?


Enable CORS in wordpress

I'm trying to enable CORS in wordpress and I've placed this line of code in my header.php file `header("Access-Control-Allow-Origin: *");` Then I tested to see if it works via this page http://client.cors- api.appspot.com/client The response I get is:               Fired XHR event: loadstart     Fired XHR event: readystatechange     Fired XHR event: error          XHR status: 0     XHR status text:      Fired XHR event: loadend      I'm not sure what I'm doing wrong here, anybody able to help me out? Thanks


Adding Menu Items in Custom Post Types

I'm creating a directory of restaurants with Custom Post Types. Each restaurant's information has its own post. I would like to be able to add the restaurant's menu items to each custom post type and I'm curious how I would achieve this. I would need to make a number of fields which contain information about each menu item - the name, price, and description. I would also need the ability to click a button that says "Add another" which would then produce another row of these fields so the user can add another menu item. I'd be very appreciative if anybody knew how to do this or had a link to a tutorial.


Search WooCommerce Products in WordPress

I've noticed that my WooCommerce products are not searched by the default WordPress search function. Any idea how to modify the function to ensure that products and product tabs are searched?


Remove WYSIWYG editor on all custom post type EXCEPT regular posts

Trying to remove the WYSIWYG Editor on all post types except the default pages and posts. Shouldn't this work               // Remove WYSIWYG Editor     function remove_wysiwyg( $hook ) {         if ( $hook != 'post-new.php' || $hook != 'post.php' )         add_filter('user_can_richedit', '__return_false');     }     add_action( 'init', 'remove_wysiwyg' );


image_resize in wp3.5 change to wp_get_image_editor and wont work

After 3.5 removed support image_resize and now says to use wp_get_image_editor as described here: https://codex.wordpress.org/Function_Reference/wp_get_image_editor Before (when it was image_resize), it would take in the image and the resize dimensions and it would resize the image and save the new file. Show as this code:               $thumb = image_resize($file, 80, 80, true);      After and trying to use the new function wp_get_image_editor doesnt quite work the same.               $image = wp_get_image_editor($file);          if ( ! is_wp_error( $image ) ) {         $image->resize( 80, 80, true );         $image->save( 'new_image.jpg' );     }      I want to be able to get the $thumb value after the resize() and save() actions are done. Any ideas or insight? I dont think that the info page has enough detail about this.


Taxonomy Tag Conditionals

I'm using jigoshop as main ecommerce plugin. Jigoshop use Taxonomies call, product_cat and product_tag. In my theme I use a default (h5bp) 404.php, so every time a tag doesn't exist I get the default 404. But I need to have a special template that give a `THIS TAG DO NOT EXIST` how can I do this? I'm using pointless:               @@@     <?php          if (is_tax()){         jigoshop_get_template( 'product_taxonomy-no.php' );     }else{      jigoshop_get_template( 'product_taxonomy-no.php' );     }     ?>     @@@      thanks


Rewrite rule that wp-login.php?action=register is left alone

Unfortunately buddypress breaks a facebook connect script because of the rewrite rules. It changes `/wp-login.php?action=register` into `/register/` I tried to find where the custom rewrite rule is located but wasn't successful. Is there any way to just add something to .htaccess that wp leaves /wp-login.php?action=register alone? I tried some things like               RewriteRule ^wp-login\.php$ - [PT,L]      but it didn't work. Any help would be awesome.


wp_nav_menu: output featured image of each page listing

Context: I am building a portfolio index where I can sort the individual project links in my sidebar by priority of appearance. I've successfully done this using the wp_nav_menu(), where each project is represented by the text name, and then I can move each Page's priority of appearance. What I get is something like this: Projects Menu List:   * Project A Page   * Project B Page   * Project C Page Now, I'd like to extend this feature by outputting the featured image associated with every individual project page so that it looks something like this: Project Menu List:   * Project A Page [+ Featured Image associated with Project A Page]   * Project B Page [+ Featured Image associated with Project B Page]   * Project C Page [+ Featured Image associated with Project C Page] Is this possible with the wp_nav_menu() call? If so, any clues on how to extend it further? Thanks!


Issues renaming images during upload

The main reason for adding this snippet is all about SEO. The people I sometimes make websites for often aren't that savvy with WP and tend to upload their stuff just as is. As these are often media related websites I try to help them a bit by automatically renaming their uploads from `DSC_0010.JPG` to `my-optimized-post-title-001.JPG`, etc. * * * I'm currently using this snippet which renames my files during upload.               add_filter( 'wp_handle_upload_prefilter', 'my_modify_uploaded_file_names', 1, 1 );     function my_modify_uploaded_file_names( $image_name ) {       // get the parent post id, if there is one       if ( isset( $_GET['post_id'] ) ) {         $post_id = $_GET['post_id'];       } elseif ( isset( $_POST['post_id'] ) ) {         $post_id = $_POST['post_id'];       }       // only do this if we got the post id, otherwise they're probably in the media section rather than uploading an image from a post       if ( is_numeric( $post_id ) ) {         // get the post slug         $post_obj  = get_post( $post_id );         $post_slug = $post_obj->post_name;         // if we found a slug         if ( $post_slug ) {           $random_number = rand( 10000, 99999 );           $image_name['name'] = $post_slug . '-' . $random_number . '.jpg';         }       }       return $image_name;     }      However, when having `WP_DEBUG` set to true it giving me this error:               Notice: Undefined variable: post_id in /home/lorem/public_html/clients/ipsum/wp-content/plugins/myplugin/test.php on line 18     Warning: Cannot modify header information - headers already sent by (output started at /home/lorem/public_html/clients/ipsum/wp-content/plugins/myplugin/test.php:504) in /home/lorem/public_html/clients/ipsum/wp-includes/pluggable.php on line 864      From the question linked to people tell it's missing the `$_GET` variables. Something I'm unable to solve myself... Does someone know perhaps on how to get this script working again? (or know perhaps a similar solution?)


Display all post types together

I'm looking to use Custom Post Types to create a simplified process for key individuals to add information to a webpage. Let's use a Job Posting as an example, with custom fields for Job Title, Closing Date, etc. However, I also have regular posts across a number of categories. I would like to have _all_ posts listed together. So for the home page where it shows the last 3 posts, that includes those in custom post types (there will be several). I would also like to have these custom posts automatically set to specific categories, but these categories should be a part of the regular post types. If "Job Postings" and "Press Releases" are two categories under my regular post menu, I would also like a CPT of "Job_Posting" to be set to "Job Postings" automatically. This is for situations where we need to post information that would _belong_ to a job posting category but wouldn't necessarily be an actual postings with the required fields set up in that CPT. Am I going about this the wrong way entirely? * * * Update: I've changed my WP_Query to the following, and it still won't show CPT:
                 <?php                  $args = array(                     'post_type' => 'any',                 );                 $recent = new WP_Query($args);                 $recent->query('showposts=3');                 if($recent->have_posts()) : while($recent->have_posts()): $recent->the_post();?>
             <a class="recent-title" href="<?php the_permalink()?>"><?php the_title()?>

<?php the_time('l, F j, Y')?>

<?php the_category(', '); ?>

<?php comments_number( 'No Comments', '1 Comment', '% Comments' ); ?>

<?php the_excerpt()?>

                 <?php endwhile ?>                 <?php else : ?>                 <?php endif ?>


Plugin uninstall function is not working

I am updating my plugin for Wordpress version 3.5 compatibility. These are my important plugin files: Sort_SearchResult_by_Title.php:               <?php     if(!class_exists('Class_Sortsearchresults'))     {     require_once('Class_Sortsearchresults.php');     }     if(!isset($Class_Sortsearchresults))     {     $Class_Sortsearchresults = new Class_Sortsearchresults;     }     ?>      Class_Sortsearchresults.php:               <?php     class Class_Sortsearchresults     {     function __construct()     {              //Register activation hook            register_activation_hook(__FILE__,array(&$this,'sortresult_install'));              //Add menu hook         add_action( 'admin_menu', array(&$this,'sort_searchresults_menu'));              //Update function hook         add_action('plugins_loaded', array(&$this,'sortsearchtitle_update_db_check'));              //Register deactivation hook         register_deactivation_hook(__FILE__, array(&$this,'sortresult_uninstall'));              //Run the search function         add_action('pre_get_posts',array(&$this,'sort_searchresult_by_title'));          }          function sortresult_uninstall()      {              //This function is not working or executed              global $wpdb;                $sortsearchtitle_db_version = '1.0';         $table = $wpdb->prefix."sortsearchresult";         $wpdb->query("DROP TABLE IF EXISTS $table");         delete_option('sortsearchtitle_db_version');     }          function sortresult_install()     {         //install function     }             function sort_searchresults_menu()     {              //function for creating menu          }          function sortsearchtitle_update_db_check()     {              //function for update              }          function settings_page()     {         //function for settings form     }          function sortingguide($opt_val)     {              //sorting options          }          function sort_searchresult_by_title($k)     {         //function to run customized search          }          }     ?>      It appears I have everything working well except the uninstall function. Any clues why this is not working? Thanks.


Customize TinyMCE Buttons

I've always used the plugin TinyMCE Advance that lets me drag and drop which buttons I want to show in the Editor. Now I'm trying to set those using my functions.php instead. That way I never have to worry about it. Here's what I've done, but I'm not seeing the results:               function myformatTinyMCE($in){      $in['plugins']='inlinepopups,tabfocus,paste,media,fullscreen,wordpress,wpeditimage,wpgallery,wplink,wpdialogs,wpfullscreen';      $in['wpautop']=true;        $in['apply_source_formatting']=false;      $in['theme_advanced_buttons1']='bold,italic,underline,|,bullist,numlist,blockquote,|,justifyleft,justifycenter,justifyright,justifyfull,|,link,unlink,anchor,|,wp_fullscreen,wp_adv';      $in['theme_advanced_buttons2']='formatselect|pastetext,pasteword,removeformat,|,hr,charmap,|,undo,redo,|,html';      $in['theme_advanced_buttons3']='';      $in['theme_advanced_buttons4']='';           return $in;     }     add_filter('tiny_mce_before_init', 'myformatTinyMCE');      Edit: It's working in WP Pages and Posts, but I'm using the Advanced Custom Fields plugin, and on WYSIWYGs created by that plugin it does not work. Is there a way to force it to work with that as well?


Creating image gallery in wordpress

Lets assume I have two following directories fruits and vegetables under my image folder and that I want to show all images on some specific page. My questions are following:   1. How to implement PHP script that will show all images from specific folder?   2. How can I implement to pull thumbnail and big image from same folder, and show them like in photobox mode, ie. once clicked on a thumbnail image, you get to big screen? I have tried modifying following
             <?php                  $temp = $wp_query;                  $wp_query = null;                  $wp_query = new WP_Query();                  $wp_query->query('showposts=-1&post_type=gallery'.'&paged='.$paged);                  while ($wp_query->have_posts()) : $wp_query->the_post();              ?>
                     <a rel="tooltip" title="<?php the_content();?>" href="                             <?php $saved_post_id = $post->ID; ?>                             <?php echo wp_get_attachment_url( get_post_thumbnail_id( $saved_post_id ) ); ?>                      ">                 <?php the_post_thumbnail('homepage-thumb');?>
                          <?php endwhile; ?>                  <?php                  $wp_query = null;                  $wp_query = $temp;  // Reset             ?>


Remove the columns in media library

How can i disable/remove the columns for Media Library? I want for **author** and **comments** column. Thanks in advance.


How can I make a post that belongs to a category or have specific tags, display different from the other single posts?

How can I make a single post display different from the other single posts when I add it to a specific category. example: I have a post that is in 3 categories: music, songs & video clips. I want every time that I add a post in category "songs", it will be displayed differently from all of the other default single posts that don't belong to the category songs. How can I do that? Also, can the same thing happen with tags too? Meaning, when I add to a post some specific tags can it change the template of the post?


How to obtain the html stripped version of $category->description?

When writing out the category description in my theme (on archives and special category listings) for example, there are times I need the description in full html mode and others when I need it returned stripped of any html. In the code below, I actually need the stripped version of the description, however $category->description returns the full description with all tags, which is rendering my strlen snippet function inoperable depending on where it breaks. How can I obtain an html stripped version of the description in the loop below?               foreach($categories as $category) {         echo '
'.get_category_thumbnail($category->term_id, 'thumbnail').'term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $category->name ) . '" ' . '>' . $category->name.'';                  if(strlen($category->description) > 300 ) echo SUBSTR( $category->description,0,STRPOS( $category->description,".",300)+1);             else echo  $category->description;


google conversion code

What is the best practice for adding google conversion tracking code to a specific page?


Get Permalink of Network Blog Post

I am trying to write a function that will allow me to specify a post ID and a blog ID, and then have it return the permalink and title of the blog post. I need this to be efficient because the function will be used in a foreach loop that could cause the function to run upwards of 50 times. Any ideas?


Showing posts by collection of specific terms and texonomy

i have a custom post type name 'business' and taxonomy 'business-category'. now i want to show posts for some specific terms suppost, term1, term2, term3 etc. The following code is working for me but for only one term.                 $args=array(         'taxonomy' => 'business-category',         'term' => 'term1',         'post_type' => 'business',         'orderby'=> 'rand',         );       query_posts($args);      I need to pass array of terms. When i try to pass array of terms instead of one term it not working :(                  $args=array(         'taxonomy' => 'business-category',         'term' => array('term1', 'term2', 'term3'),         'post_type' => 'business',         'orderby'=> 'rand',         );       query_posts($args);      I also want to know how can i show post if i want to show from multiple taxonomy as well. Thanks! * * * Resolved: the query args will be:                   $args=array(                 'tax_query' => array(                               array(                                     'taxonomy' => 'business-category',                                     'field' => 'slug',                                     'terms' => array( 'bars', 'restaurants' )                                )               );      Thanks!


The Great Plugin Nomenclature Contest of 2011

It's been a while since I've done a bounty challenge, so here's another. Same basic rules: 1 answer per person, most creative/useful/helpful/entertaining answer wins. This time around, the award will be 50 reputation points via a Bounty. This challenge is for my in-development plugin, **Crossfire**. ## Plugin Purpose Allows authors of multiple sites on a multisite network to cross-post their content from one site to another. ## How it Works Authors write a post as usual on the primary site. Then they select the sites to cross-post from a meta box. WordPress uses a custom post type to keep track of the cross-posted content on the sister sites. ## Endgame   * Visitors to both the main site and the sister sites will see the new post at the top of the page.   * Comments on one site are automatically mirrored to all the others.   * Feed subscribers will only see the new post in the original site's feed. As I said, the plugin will be called **Crossfire** , but I need a creative name for the custom post type used on sister sites (where the post content is imported). Calling them "posts" isn't accurate since they won't show up in the site's feed. So, give me your best ideas and the _best_ of the best will be awarded 50 reputation points! Contest ends Friday, April 23 at 19:00 UTC (12:00 Pacific).


How can I make it so the Add New Post page has Visibility set to Private by default?

I'm trying to create a plugin that alters the Add New Post page so the Visibility field says "Private" by default:               Status: Draft     Visibility: **Private**     Publish immediately          [Publish]      ...as opposed to what WordPress normally assumes:               Status: Draft     Visibility: **Public**     Publish immediately          [Publish]      At the moment, I'm using the "wp_insert_post_data" filter, and that is allowing me to change any posts with a post_status of "auto-draft" to "private". While this works, there is an unintended side-effect: Changing the post_status to "private" seems to publish the post automatically, changing the button in the editor to "Update". Furthermore, if the user saves before specifying a title, the post will be published with the title "Auto-Draft". Is there any way I can simply change Visibility to Private by the default, in a manner that doesn't auto-publish the post, and change the button to "Update"? In vanilla WordPress, users can manually change the visibility to Private, and the button remains as Publish... I just need to achieve that via a plugin. I also want to ensure that "public" can still be selected by the user, should they desire to. Thanks!


What's the best place to hire a freelance (contract) WordPress developer?

I'm looking to hire someone for ongoing work. Where should I be looking? I posted on Craigslist, oDesk, and Freelancer. I'm also going to check out CodePoet.com and jobs.wordpress.net.


wp_nav_menu sort order?

Hey Guys, I'm trying to build a right aligned, wrapping capable wp_nav_menu powered menu. Is there a way to have it rendered backwards, so that float: right; would work and not mess up the order? I was hoping for something like this:               <?php wp_nav_menu( array('sort_order' => 'DESC' )); ?>      Thanks!


register_activation_hook() not activate plugin

I am writing a plugin that on the activation must create a new table in database. To do this i am using:               register_activation_hook( __FILE__, 'createTable' );      When i run the activation, my plugin creates the new table in the database but when the plugin-page is reloaded my plugin is listed as not active. So i have still the links: activate|delete. Why this happends? how to fix? Here is my function:                   function createTable(){                   $link = mysql_connect('localhost', 'user', 'pass');         if (!$link) {             die( 'Could not connect: ' . mysql_error() );         }         mysql_select_db (db_name);               $sql = "CREATE TABLE IF NOT EXISTS UsersExtra (           user_id INT NOT NULL,           first_name VARCHAR(25) NOT NULL,           last_name VARCHAR(25) NOT NULL,           address VARCHAR(80) NOT NULL,           city VARCHAR(30) NOT NULL,           province CHAR(2) NOT NULL,           postcode CHAR(7) NOT NULL,           interests TEXT NULL,           bio TEXT NULL,           signature TEXT NULL,           skills TEXT NULL,           PRIMARY KEY (user_id),           FULLTEXT KEY (interests, skills)         ) ENGINE=MyISAM  DEFAULT CHARSET=utf8";              mysql_query($sql) or die( mysql_error() );         mysql_close($link);          }


BuddyPress - Redirects on Login and Logout

Using BP theres a way to:               1. On login redirect to member profile.          2. On logout redirect to facebook.com      Thanks in advance.


__autoload in a plugin throws an error in WP - not able to locate translation_entry.class.php

Ok, I'm going to try to explain this as simple as possible. I'm trying to modify a plugin called smart-lencioni-image-resizer v2.0. to be used in WP-Multisite. I'm trying to display an image through SLIR using the following URL: http://subsite.mainsite.no/wp-content/plugins/wp- filebrowser/slir/?w=90&h=90&c=1:1&i=http://bekkelaget.stiengenterprises.no/files/seniorsenter/DSC_3535.jpg I've done this successfully in v.1.4.2. But v2.0 is using a different method for including files. The `index.php` file looks like this:               function __autoload($className)     {       var_dump($className);           require_once strtolower($className) . '.class.php';     }          new SLIR();      Now, where ever I try to include WP header:               require_once($_SERVER['DOCUMENT_ROOT'].'/wp-blog-header.php');      I get the following error message: * **Warning: require_once(translation_entry.class.php) [function.require-once]: failed to open stream: No such file or directory in I:\Development\wamp\www\mysite\wp-content\plugins\wp-filebrowser\slir\index.php on line 43*** Line 43 in the `index.php` is:               require_once strtolower($className) . '.class.php';      For some reason the `__autoload` function makes WP look for files in the SLIR directory. This is of cours wrong :( **UPDATE** I found one solution on the web that kind of works:               function __autoload($className)     {       if(file_exists(strtolower($className) . '.class.php')) {         require_once strtolower($className) . '.class.php';       }     }      This allows WP header file to be loaded. But for some reason it loads `mainsite.no` and drops executing the URL I added at the top. Is there any other way I can solve this problem? **UPDATE2** There is an .htaccess file in the SLIR folder. The file looks like this:               <IfModule mod_rewrite.c>     RewriteEngine On     RewriteRule . index.php [L]     </IfModule>          # Prevent viewing of the error log file in its default location     <Files slir-error-log>     Order Deny,Allow     Deny from All     </Files>      Could it be that when I include the WP header file, it ignors the .htaccess file from SLIR?


How do I create a system to track logged in users' views each time an individual CPT post is viewed?

I have a custom post type created in a plugin I'm working on, using Piklist (as I have a lot of other things I can use it for in this project, in general). So my first step would be to create a table to store the data.               global $vl_db_version;      $vl_db_version = "1.0";          function vl_install() {          global $wpdb;          global $vl_db_version;         $table_name = $wpdb->prefix . "listingviewlog";         $sql = "CREATE TABLE $table_name (              id mediumint(9) NOT NULL AUTO_INCREMENT,              time datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,              name tinytext NOT NULL,              text text NOT NULL,              url VARCHAR(55) DEFAULT '' NOT NULL,             UNIQUE KEY id (id)          );";         require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );          dbDelta( $sql );         add_option( "vl_db_version", $vl_db_version );      }          function vl_install_data() {         global $wpdb;          $welcome_name = "Mr. WordPress";         $welcome_text = "Congratulations, you just completed the installation!";         $table_name = $wpdb->prefix . "listingviewlog";         $rows_affected = $wpdb->insert(              $table_name,              array(                  'time' => current_time('mysql'),                  'name' => $welcome_name,                  'text' => $welcome_text              )          );      }      But the fields I actually need after id and time are not name, text, and url, but user_id and cpt_id, foreign keys... or do they need to be foreign keys? Why should they be? Because the actual logging action code should add those in anyway right... Then I'll use Piklist to make an admin table and stats section.


how to add a page

It's probably really simple, but i can't figured out, i have a php file and 3 folders css, js( with inside libs ), and image. so i put the php file and the css inside the theme root, the js in /js folder. after that i just created a new page and use as template attributes the about. doesn't work http://www.inspirates.net/?page_id=554 there is the file: http://pastebin.com/YYP31cfr i don't know what is wrong, i know there are a lot of topic about custom page, but my problem is to include all the file.


Get custom fields when hover link of post

I have custom page and get some links of post               if( $my_query->have_posts() ) {            while ($my_query->have_posts()) : $my_query->the_post(); ?>
<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>" target="_blank"><?php echo str_replace($xx,'',get_the_title()); ?>
              <?php            endwhile;          }      I want to get custom fields (e.g description, post-image) of post when hover every link of post and put them into `div` (tooltip), do I create new file for get custom fields and get file using ajax or just call using wp_query to get custom fields?


Styling Taxonomy Terms Individually

I am trying to solve a problem and need help :) First, I have a custom grid displaying terms and images from my custom taxonomy. This is the code I'm using currently:               <?php          $terms = get_terms( 'industrygroups' , 'hide_empty=false' );          echo '
';          foreach ( $terms as $term ) {              // The $term is an object, so we don't need to specify the $taxonomy.         $term_link = get_term_link( $term );              // If there was an error, continue to the next term.         if ( is_wp_error( $term_link ) ) {             continue;         }              // We successfully got a link. Print it out.         echo '
' . $term->name . '
';     }          echo '
';          ?>      What I would like to accomplish now is to use a custom field from my taxonomy term (which has been added via ACF. The field is a dropdown, displaying different Levels 1-5. I want each chosen level to output a different color border/background around the tax term shown in the grid - In the Front End Now, I have been trying to follow this tutorial which addresses how to accomplish this with posts, however I'm struggling to transfer this train of thought to apply to taxonomy terms. I would love some advice. Thank you.


setlocale for date

So I purchased a premium wordpress theme, but I can't get through its Polish localization - the dates outside the_time or the_date are displaying in English (default server's language). I read that I have to use setlocale(LC_ALL, 'pl_PL'); to change it, but I don't know in which file or where it should be included and/or if I need something more. Below is an excerpt of code displaying English date:               $event_date = get_post_meta(get_the_ID(), 'event_date');     $event_from_time = get_post_meta(get_the_ID(), 'event_from_time');     $event_to_time = get_post_meta(get_the_ID(), 'event_to_time');     $event_address = get_post_meta(get_the_ID(), 'event_address');          echo date('j F Y', strtotime($event_date[0])).'  '.$event_from_time[0].' do '.$event_to_time[0];      I appreciate your time and help.


Wordpress - Allow dynamic text to be added into a sidebar upon page creation

I have a page template in WordPress that allows new pages to be created to display and explain treatment details. E.g.   * Chiropractor Page   * Acupuncture Page When a new treatment page is created from the template, it is required to put which clinics provide the treatment in the sidebar. The clinics listed will vary for most treatment pages so this information cannot be hard-coded. I'm unsure on how I should be doing this? I have a unique sidebar that the template uses but I'm not sure how I incorporate this dynamic functionality into that sidebar? I guess it would make most sense that when I create the page within WordPress, there is something like the 'Featured Image' option where I can drop this information in. All help is greatly appreciated. Thanks


Global Parent theme for all sites

I have 15 different wordpress sites installed on my server. They are independent installations , not multisite. I have developed a parent theme and copied it in all sites. Now whenever I have to make a change in parent theme, I have to access parent theme of all sites and make changes in each theme. Is it possible that I can globalize this parent theme such that I do change on one place and it reflects on all 15 sites (Without using Multisite feature). Though I wrote a php script that copies parent theme in all sites but not satisfied since I have to call that script everytime.


WordPress not working locally

I am attempting to get a local version of a live WP site working. I have pulled down the entire file structure. I have a copy of the DB. After setting up locally, I get a few random issues such as:   1. Permalinks not working properly   2. Javascript error   3. Content generally not loading properly.   4. 500 errors (probably caused by the .HTACCESS)   5. This error caused by a plugin: **Warning: Parameter 1 to ace_where() expected to be a reference** I suspect it has something do with a server setting of which I am unaware. The live server is IIS. I am running OSX with the built-in Apache. I have many other WP installations working fine locally. Any thoughts, comments, or suggestions are appreciated. Here is the .htaccess:               RewriteEngine on     RewriteCond %{HTTP_HOST} ^client.com$     RewriteRule ^(.*)$ "http\:\/\/www\.client\.com\/$1" [R=301,L]     # BEGIN WordPress     <IfModule mod_rewrite.c>     RewriteEngine On     RewriteBase /~client/     RewriteCond /home2/client/public_html/wp-content/sitemaps%{REQUEST_URI} -f     RewriteRule \.xml(\.gz)?$ /~client/wp-content/sitemaps%{REQUEST_URI} [L]          RewriteRule ^index\.php$ - [L]     RewriteCond %{REQUEST_FILENAME} !-f     RewriteCond %{REQUEST_FILENAME} !-d     RewriteRule . /~client/index.php [L]     </IfModule>          # END WordPress


Why the custom post type links don't work if not login?

I have created a custom post type "events" to display event information. All links to the events work well when I am logged in. However, if I am not log in, all the links for events that set in the future are broken - having a page not found message; but these pages will display as soon as I log in. -- all links for events in the past are working well no matter log in or not. Please advice what cause the problem and how to fix it. Thanks I have the following code in the functions.php in my child theme:               function enable_event_posttype() {         register_post_type( 'events',             array(                 'labels' => array(                     'name' => __( 'Events' ),                     'singular_name' => __( 'Event' ),                     'add_new' => __( 'Add New Event' ),                     'add_new_item' => __( 'Add New Event' ),                     'edit_item' => __( 'Edit Event' ),                     'new_item' => __( 'Add New Event' ),                     'view_item' => __( 'View Event' ),                     'search_items' => __( 'Search Event' ),                     'not_found' => __( 'No events found' ),                     'not_found_in_trash' => __( 'No events found in trash' )                 ),                 'public' => true,                 'scheduled' => true,                                  'supports' => array( 'title', 'editor', 'comments'),                 'capability_type' => 'post',                 'rewrite' => array("slug" => "events"), // Permalinks format                 'menu_icon' => get_bloginfo('stylesheet_directory') . '/images/date.png',  // Icon Path                 'menu_position' => '5'             )         );     }          add_action( 'init', 'enable_event_posttype' );


Order Custom Post Type Archive by multiple values in functions.php

Sorry in advance for my limited PHP skills. I saw this post and the function helped to fix my pagination problem for the archives pages for my custom post type. pagination doesn't show up for custom post type The challenge I have is I need this same type of function to account for ordering the archive in ASC order and by a custom field value which is tied to a DATE value I created. I'm trying to figure out how to write the function by grabbing code from other places and trial and error. I'm hoping someone here can point me in the right direction. Thank you for your thoughts. RESOLVED... SORT OF I added these other $query->set parameters and it seems to work for the archive listing / _CUSTOM ARCHIVE FOR EVENTS_ / function events_pagesize( $query ) { // exit out if it's the admin or it isn't the main query if ( is_admin() || ! $query->is_main_query() ) return; // so its not admin, and its the main query, is it the tr-events post archive? if ( is_post_type_archive( 'tr-events' ) ) { // it is!! Set the posts_per_page to 6 $query->set( 'posts_per_page', 4 ); $query->set( 'order' , 'asc' ); $query->set( 'meta_key', 'wpcf-tr-order- date'); $query->set( 'orderby', 'meta_value'); return; } } add_action( 'pre_get_posts', 'events_pagesize', 1 ); While not ideal, for other page templates, this works for the Custom Post Type Archive page.


Autologin only working the second time

I want to auto-login visitors to WP through email links. I use a "userid" parameter with their email and a "redirect_to" one to know where to point them. There are some protected areas in the site, just for registered visitors, and they can't see them if they don't log in first (that's the reason of the auto-login). My problem is that the auto-login works fine, but only the second time someone follows the link. Otherwise, they get a message saying that page is protected. Should I try another hook? This is my code:               class zelfunctions     {            public function __construct()       {         add_action( 'init', array(&$this, "autologin"));       }            public function autologin(){        if (!is_user_logged_in()) {              $redirect = isset($_GET['redirect_to']) ? esc_attr($_GET['redirect_to']) : false;          $useremail = isset($_GET['userid']) ? sanitize_user($_GET['userid']) : false;         if ($user = get_user_by( 'email', $userid )) {           wp_set_current_user($user->ID, $user->user_login);           wp_set_auth_cookie($user->ID);           do_action('wp_login', $user->user_login);           if (!$redirect) {           //If there isn't any redirect set, just redirect to the home (already logged in)              $final_url = home_url('/');           } else {              $final_url = home_url('/'). $redirect;           }           wp_redirect($final_url);           exit;           }         }             }     }


Set jpeg_quality for certain post-types

Without using timthumb, does anyone know of a way to set jpeg_quality for certain post-types or posts?


Plugin list-category-posts - How can I use "id" or "name" parameters?

In "list-category-post", the shortcode parameter options [catlist **id=1,2,3** ],[catlist **id=-99** ],[catlist **name='TestCategory'** ] don't work correctly. It always shows posts from **All categories**. How do I use "id" or "name" option? All other options are shown correctly. My WordPress version is 3.3.1 and I use twentyten theme. My code is below:               [catlist id=-1,-2,-3 thumbnail=yes thumbnail_size=thumbnail orderby=date order=DESC numberposts=10 date=yes author=yes excerpt=yes excludeposts=999,1000,1001 content=no catlink=yes comments=yes morelink="Read more" categorypage=yes post_type=post]


Issue when showing metabox value on post type permalink?

I want to show the custom post type value on permalinks like yourdomain/metabox_value/post_title. By the below code I achieve the goal but after appling this code only this post type permalinks is working but other pages and post permalinks are not working. Please, let me know the solution. What is the error on my code? Here listing is post type name and city is metabox               add_action('init', 'tdd_add_rewrite_rules');     add_filter('post_type_link', 'tdd_permalinks', 10, 3);     function tdd_add_rewrite_rules()     {         global $wp_rewrite;         $wp_rewrite->add_rewrite_tag('%listing%', '([^/]+)', 'listing=');         $wp_rewrite->add_rewrite_tag('%VARIABLE1%', '([^/]+)', 'VARIABLE1=');          $wp_rewrite->add_permastruct('listing', '/%VARIABLE1%/%listing%', false);      }     function tdd_permalinks($permalink, $post, $leavename)     {             global $post;         $no_data = 'no-data';         $post_id = $post->ID;         if($post->post_type != 'listing' || empty($permalink) || in_array($post->post_status, array('draft', 'pending', 'auto-draft')))             return $permalink;         $var1 = get_post_meta($post_id, 'city', true);              $var1 = sanitize_title($var1);          if(!$var1)         $var1 = $no_data;            $permalink = str_replace('%VARIABLE1%', $var1, $permalink);            return $permalink;     }


Using ajax on categories and wordpress loops

I want my index.php to be a simple page with a horizontal list of category names on the top. But instead of having the page reload with the list of posts in that loop each time a category is clicked on, I want the set of posts from each category to display instantaneously after every click on a different category. Is this possible in Wordpress?


Wordpress Author Posts Review After Every Change In The Same Worpress Post

guys pardon my english, I am new to wordpress & I have been trying to set up a wordpress website for product reviews where new users will submit their reviews for the product/products. New user who registers on the website will have the role of a 'Author'.   1. User 'XYZ' registers on the website.   2. 'XYZ' wants to add a review of the product.   3. 'XYZ' submits the review.   4. Admin user 'ABC' gets notified via email that the new post has been pending for the review.   5. 'ABC' approves & publishes the review/post on website. **Now the problem is that** XYZ user can again make changes in the same post and can publish them without the approval admin user a.k.a ABC ,because the post have been already approved. This can cause problems. **What I want to do is** Every time 'XYZ' user make changes in the post which is already approved, the post should be approved by the admin a.k.a 'ABC' user again.


Toggle nested comments

I am trying to find a solution to toggle (hide/show) threaded comments. I need to see only comments 1,2,3 etc... and hide 1.1,1.2,1.3 etc... Clicking "show comments" will toggle and display the thread of comments. example: 1 --- -----clicking "show more comments" shows ----- 1.1 ----- 1.2 ----- 1.3 ----- ... 2 --- -----clicking "show more comments" shows ----- 2.1 ----- 2.2 ----- 2.3 ----- ...


Wordpress Post # of # filtered by category slug

I want to show post #4/100 at the top for each post for which I'm using following code               function updateNumbers() {     /* numbering the published posts: preparation: create an array with the ID in sequence of publication date, /     / save the number in custom field 'incr_number' of post with ID  /     / to show in post (within the loop) use <?php echo get_post_meta($post->ID,'incr_number',true); ?>     / alchymyth 2010 */     global $wpdb;     $querystr = "SELECT $wpdb->posts.* FROM $wpdb->posts WHERE $wpdb->posts.post_status = 'publish' AND $wpdb->posts.post_type = 'post' ";     $pageposts = $wpdb->get_results($querystr, OBJECT);     $counts = 0 ;     if ($pageposts):     foreach ($pageposts as $post):     setup_postdata($post);     $counts++;     add_post_meta($post->ID, 'incr_number', $counts, true);     update_post_meta($post->ID, 'incr_number', $counts);     endforeach;     endif;     }            add_action ( 'publish_post', 'updateNumbers' );     add_action ( 'deleted_post', 'updateNumbers' );     add_action ( 'edit_post', 'updateNumbers' );          <?php echo get_post_meta($post->ID,'incr_number',true); ?>      This code seems to work fine for me but I just want to filter posts by category slug & only count posts for that particular category Thanks


Delete some text and change html tag with Jquery

Im looking a way to change the following HTML:
Rating: +5 (from 5 votes)
      and produce:

+5

      Thanks in advance.


WP_Query meta compare must include ALL array values

I am allowing users to query posts using a form with checkboxes. I want the posts to be filtered by the checkboxes but instead of showing all posts that include the ANY of the meta values selected I want to show posts that contain all of the selected values. Is this possible? Here is what I currently have using the "IN" operator which just checks if the post contains any single value in the array.               $the_query = new WP_Query(array(                 'post_type' => 'listing',                 'posts_per_page' => -1,                 'post_status' => 'publish',                  'category_name' => 'private_rental',                 'orderby' => 'rand',                 'meta_query' => array(                         'key' => 'row_amenities',                         'value' => $amenities,                         'compare' => 'IN'                         )             ));


Add a button or image button that calls wp functions in the wp-admin

I have a custom post type of products that I've setup to upload PDF's using metaboxes. When I generate the metaboxes on the wp-admin, I look to see if the metabox already has a pdf uploaded to it or not. If it DOES I generate a link to the pdf. If it doesn't I generate a file upload control where they can pick a file to upload if they want. Here's what my function looks like that generates this metadata.               function products_pdf_uploads_show_meta() {         global $meta_box_pdf_uploads, $post, $prefix;              echo '
';         echo '
Upload your PDFs here
';         foreach ($meta_box_pdf_uploads['fields'] as $field) {                         //Get current PDF meta             $pdf_array = get_post_meta($post->ID, $field['id'], true);             //Grab the filename from the end of the path             $pdf_filename = substr(strrchr($pdf_array['url'], "/"), 1);                  echo '
',                     '';                                              //If Empty, show file upload dialog                         if(empty($pdf_array)) {                              echo '<input type="file" style="width: 700px;" name="', $field['id'], '" id="', $field['id'], '" />';                              } else {  //Else if pdf exists, show link to pdf and add DELETE button                             echo '
'. $pdf_filename . '
';                         }                  echo    '	',                  '
';         }         echo '
';      What I'd like to do is if there is a PDF metadata (meaning there's a pdf already uploaded), I'd like to put a DELETE button next to the PDF Link.                } else {  //Else if pdf exists, show link to pdf and add DELETE button           echo '
'. $pdf_filename . '
' ;           //I Want to add a delete button after the above echo          }      The delete button will remove all metadata from the PRODUCT post type, and delete the file off the server. SO I guess my question is how can I make a button that hooks into wordpress functions such as `delete_post_meta` ? I'm using `wp_upload_bits()` to upload the pdf's mostly because I don't want the PDF's added to the media library, just want to upload them to the server and get a path. Thanks!


How to use post_id with a Class?

I made a plugin for some calculation.               Class Math {     var $id; // I want to map this id to post_id     var $a;     var $b;     var $c;          function calculate{      $this->a = $value_from_post_meta_input_box;      $this->b = $data_generated_in_calculating_process;      $this->c = $result_of_some_function;     }     }      After activating the plugin, and setting up the post meta input box for $a, I am able to get $a saved in post meta. Now, how can I save $b and $c to post meta? How to say the current calculation is an instance of Math with current post_ID ?


Theme Stylesheet Loads Into Dashboard

I am hoping that I am authorized to post this. I saw another thread but I don't seem to be authorized to comment or answer or otherwise ask any questions about it. The site in question has been up and running for over a year, and only in the last few days did I notice this issue when I went to add a category. When I load my dashboard, it comes up normally, then it loads the dashboard with the theme's css, and loads the site under Wordpress news - it looks to be doing that at the same time Wordpress News is loaded. Then it refreshes again, and goes to a blank screen. I have tested this by turning off all of my plugins, changing to theme twenty-fourteen, deleting wp-admin/wp-includes and all other standard wp files and re ftp-ing them. I've ensured I have nothing extra in my .htaccess file, or in my wp-config.php file. I've removed wp-super-cache and all related files, removed ithemes security and all related files and database entries. The site looks fine, but I can not manage the site from the dashboard,and I'm not able to add categories to my posts. I'm at a loss, and apparently not very many people have run into this problem, so I'm having a problem diagnozing it.


Count images in post then add class if just one

I'm trying to add a function to my site that will count the number of images attached to a post, and if only one, to add a class to either that `<img>` or to the containing `<a>`. I think I'm fairly close, but don't have the PHP syntax skills to finish it up. The code I've hacked together, sourced from various threads on the topic, is:               /**      *      * Single-image posts will receive a separate class name      *      */          add_filter( 'the_content', 'single_image_content_filter', 20 );          // Count images in post     function single_image_content_filter( $content ) {          $attachments = get_children(array('post_parent'=>$post->ID));     $imgcount = count($attachments);              // If only one attachment, add a new CSS class         if ( $imgcount === 1 ) {                  global $post;             $classes = 'single-img'; // separated by spaces, e.g. 'img image-link'                  // check if there are already classes assigned to the anchor, and/or add one via $classes             if ( preg_match('/<a.*? class=".*?">/', $content) ) {             $content = preg_replace('/(<a.*? class=".*?)(".*?>)/', '$1 ' . $classes . '$2', $content);           } else {             $content = preg_replace('/(<a.*?)>/', '$1 class="' . $classes . '" >', $content);           }          return $content;              }     }


WPML: getting page title in different language

i'm running my web in english and german using the WPML plugin. my question: when in english mode - is it possible getting the page_title() but in german? thanks


H1 tags for header image?

In `heading.php` of the Leaf Theme there is the following code: * * *                   <?php $header_image = get_header_image();         if ( ! empty( $header_image ) ) { ?>             <a href="<?php echo esc_url( home_url( '/' ) ); ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home">                 <img src="<?php header_image(); ?>" width="<?php echo get_custom_header()->width; ?>" height="<?php echo get_custom_header()->height; ?>" alt="" />                     <?php } else { ?>              <hgroup>
<a href="<?php echo home_url( '/' ); ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?>

<?php bloginfo( 'description' ); ?>
              </hgroup>             <?php } ?>      I want to add a text to the header image and wrap that text into H1 tags for the homepage and h6 for all other pages. _The Else part doesn't have too much importance as I will only be using a image. I included it because it´s part of the code._ I have tried for a while now but I simply don´t know enough of PHP to pull it off.


Search options/filters

I'm trying to add some checkbox options to a sidebar search box, similar to this, where the user has the option to choose whether to search `All Words`, `Some Word`, or the `Entire phrase`. I did find this after some searching - Wordpress Search Phrases. The 'sentence' option seems to work well, but the others not so good. The code below is what I'm working on at the moment, but would really appreciate some help to get this working properly. Many thanks in advance, S. (I do not wish to use plugins for this).               <form action="<?php bloginfo('home'); ?>/" method="post">
                 Search the site                            <input type="text" name="s" id="search" value="Enter search term" onblur="this.value = this.value || this.defaultValue;" onfocus="this.value = '';" />                       <input type="submit" name="submit" value="GO" class="s-btn" />
Search Options

          <input type="radio" name="sentence" value="" checked="checked" />All Words
          <input type="radio" name="sentence" value="or" />Some Word
          <input type="radio" name="sentence" value="and" />Entire phrase

</form>          **EDIT: The answer below doesn't actually work after all : ( Anybody else have any ideas please?**


How to have H1 for site title only on Homepage?

I´m using the Leaf Theme and in the header the following code can be found:               <?php $header_image = get_header_image();                             if ( ! empty( $header_image ) ) { ?>                                 <a href="<?php echo esc_url( home_url( '/' ) ); ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home">                                     <img src="<?php header_image(); ?>" width="<?php echo get_custom_header()->width; ?>" height="<?php echo get_custom_header()->height; ?>" alt="" />                                                              <?php } else { ?>                                  <hgroup>
<a href="<?php echo home_url( '/' ); ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?>

<?php bloginfo( 'description' ); ?>
                             </hgroup>                                  <?php } ?>      Right now the on all pages the site-title has the H1 tag and the site- description the H2 tag. I want this only on the homepage. On all other pages the title should have H6 and the description H7. How can I do this? _The first part of the code is for when you use an image instead of title/description. I included it because it is included in the php if_


User capability of create page/new page

I am working with the Role and Capabilities API for the first time today and making use of the the excellent Members plugin. Having tinkered around for some time I notice that the "edit pages" capability does two things:   1. Allow the user to create a new page   2. Allow the user to edit existing pages I am trying to split this capability into two. I want my user to:   1. Not be able to create any new pages   2. Allow the user to edit existing pages I am looking to write some code for my theme that allows this to happen. I can create a new capability very easily. The challenge is then getting WordPress to respond accordingly to it. Any thoughts would be appreciated.


Multiple developers / editors working on a site in progress

**Background** I'm nearing the final stages of constructing my first fairly large WordPress site, and I'm now encountering some friction. For the most part, the site was developed on my local machine and I would push changes up to a staging server for review (see this question for more background). The solution I ended up with worked quite well when it was just me editing content, but now some other people are editing the content while I still have features to add. The idea was: we could get things done more quickly if the features and the content came together in concert... but now I'm not so sure. Currently there is different content in the database on the staging server than on my local machine. That's fine by itself, as I don't need the final body copy on my local machine, but I need to do more development which will affect the database (install/write a couple more plugins which need their own tables). **My question is:** Is there an easy way to automate the merging of databases so that multiple people can work on a WordPress install? I could, of course, just export the tables which I _know_ have changed on my local machine and push them to the staging server, but it's possible that there are also things on the staging server I would like to bring down. I could grab the SQL output of both DBs and diff them... but that seems tedious and hackish. I'm wondering if this is a problem others have solved; if there's a community-accepted way to handle this sort of thing. Thanks!


Visiting posts results in 404 errors after host migration

I have migrated my WordPress blog from one host to another by way of transferring the files and exporting/importing my database, updating URL references where needed. On my new host, I can successfully view the front-page of my blog however visiting posts results in "404 - Page not found" errors, seemingly regardless of my permalink settings. My blog as it resides on the new host can be found at www.erogol.com Any one know the reason?


Way to check if we are in Theme Customizer mode?

> **Possible Duplicate:**   >  How to execute conditional script when on new customize.php (Theme > Customize) screen Is there a Conditional Tag, or any other method, that we can use to check if we are customizing the theme? I want to include some extra stylesheet while customizing the theme. so I'd like to have sth like:               if ( theme-customizer-is-active ) {         // load some extra styles     }


How to hide some options from a select with functions.php

In page and post editor page Wordpress i've a box provided where i can choose from a select, for example: Select sidebar to associate with this page:               <select id="#idselect">     <option value="s1">Sidebar 1</option>     <option value="s2">Sidebar 2</option>     <option value="s3">Sidebar 3</option>     <option value="s4">Sidebar 4</option>     <select>      I want to hide options depending on user role. If i'm ADMIN-1 i want to disable selection and set only "s1" in the select. If i'm ADMIN-2 o want only "s2", etc.... How can i hide options i don't want when i enter in backend editor for pages and posts with functions.php? Is it possible? Thanks a lot


Heartbeat API: How to access data already enqueued?

I'm having problems when trying to access data that I've queued using the Heartbeat API. I'm queuing data using `wp.heartbeat.enqueue()`. For example:               var data = {          my_key: 'value'     };     wp.heartbeat.enqueue( 'my_handle', data, false );      Then later on in my script, I'd like to access the data I've queued. For example:               $( document ).on( 'click', '#button', function() {         // Here, I want to access the data I've enqueued.     });      I've tried doing the following but that doesn't work:               $( document ).on( 'click', '#button', function() {         var my_data = wp.heartbeat.getQueuedItem( 'my_handle' );         alert( my_data.data.my_key );     });      Hoping someone can suggest where I'm going wrong?


Plugin error on activation - breaks page encoding and prints the code of plugin php files

I have WordPress multisite install, everything was working properly. Developed a custom pugin on my local server (same configuration of Nginx, PHP, MySQL, Memcached, the only difference is OS - Windows 7 locally vs Ubuntu 14.04 LTS on server) and it works just fine. Plugin handles custom front-end reistration, login, password reset and user activation, custom profile page and profile editing (profiles are custom post type with some custom taxonomies). All forms are submitted via ajax. Everything works locally. When I try to activate the plugin on a server it kind of activates but completely messes up cyrillic encoding and prints some code from my plugin files on top of the pages (frontend and backend). Tried to disable all plugins and themes, revert to default. I even switched to new empty database, installed network again and activated on a fresh install. Same error. I also have this function in one of my files:               add_action( 'init', 'feup_output_buffer' );     function feup_output_buffer() {              ob_start();          }      So it can't be 'header already sent' issue (and if yes - it would throw a php warning). Debug is on, no php errors, warning or notices. Any ideas? Here's the screenshot ![enter image description here](http://i.stack.imgur.com/LlIra.jpg)


register child class in another plugin

I think this should be relatively easy, but somehow I cannot figure out how to do this. essentially there's a preexisting plugin that does this:               add_action('widgets_init', create_function('', 'register_widget("Foo");'));     if ( ! class_exists( 'Foo' ) ) {     class Foo extends WP_Widget {             /*constructs etc*/     }}      now i would like to write another plugin (extension essentially), that extends the above. I tried to do something like the following (and also tried - in vain - to find some examples/documentation )               add_action('widgets_init', create_function('', 'register_widget("Bar");'));     class Bar extends Foo {              function __construct() {             /*do stuff*/         }     }      but all i ever get is               <b>Fatal error</b>:  Class 'Foo' not found in ...      so I suppose it's a question of making 'Bar' execute AFTER Foo, but I dunno how. any hints/ideas/snippets or even just links to docs etc would be much appreciated as I am failing at the first hurdle here..:(


User's total comment count excluding comments on their own posts

I'm currently working on a plugin that I hinted at here and so far I have managed to code everything, only missing one piece of the puzzle. This is how I get the total comment count for the `current_user`:               global $wpdb, $current_user;     get_currentuserinfo();     $userID = $current_user->ID;          $where = 'WHERE comment_approved = 1 AND user_id = ' . $userID ;     $comment_count = $wpdb->get_var("SELECT COUNT( * ) AS total           FROM {$wpdb->comments}          {$where}");          echo 'Total Comments: ' . $comment_count;      I want to `echo` the `current_user`'s total comment count on **other users posts** , so I don't want to count the comments on the author's own posts. Is such thing possible? And if so, how?


Add a Custom Field in Comment Box AFTER text area BUT BEFORE Send button

I was inspired by this Q&A: Add a Custom Field in Comment Box next to the Text area but I have to insert the custom field after the textarea but before the Send button. I did not found the proper action to customize and I guess it not exists at all. comment_form_after_fields puts my output before textarea   comment_form_after puts my output after Send button Am I wrong?                   add_action( 'comment_form_after', 'test');          function test(){         echo "TEST";     }         add_action( 'comment_form_after_fields', 'test');          function test(){         echo "TEST";     }


Remove Woocomerce shop page

I know this question is about Woocomerce but I want to give it a try. Is there a way to remove the shop page? I use them as parts of a custom post type, and I don't need that page, but it exists. What is the best way to remove or hide this page from users?


How to map secure.domain.com to www.domain.com or domain.com with "WordPress MU Domain Mapping" on the primary multisite domain?

We have a multisite setup, the primary site needs to have `example.com`, `www.example.com` and `secure.example.com` mapped in wordpress so the primary site's content loads on them. `secure.example.com` will be over HTTPS. The problem we are facing is everything except `secure.example.com` works. When attempting to access `https://secure.example.com` there is a `302` redirect to: `http://www.example.com/wp-signup.php?new=secure.example.com` `secure.domain.com` has a SSL Certificate to server secure content. Obviously it can't just redirect otherwise it wouldn't be secure any longer. WordPress MU Domain Mapping is installed but doesn't appear under the primary site's menus. When trying to access the plugin directly via `~/wp- admin/tools.php?page=domainmapping` we recieve the message > "You do not have sufficient permissions to access this page." Note: We are logged in as Super Admin. Any suggestions regarding to this would be highly appreciated.


Custom wp_trim_words() function not trimming right

I have this custom `wp_trim_words()` function set to give me excerpts of only 20 words, and for the most part, it works fine. Except for some reason, on posts that contain lists, it outputs way more than 20 words. (See the posts at the bottom of this page.) How can I fix this? I tried removing `<ul>,<ol>,<li>,` from the `function insight_allowedtags()` but that did nothing. Ideally, I'd like to make the custom excerpt output at least 20 words and end at the end of a sentence regardless of whether or not the post contains a list. This is the custom function I am using (as suggested in this post):               // Custom Excerpt for Insights Posts on Insights Page & Category Pages     function insight_allowedtags() {         // Add custom tags to this string             return '


Why won't my site automatically apply updates after upgrade to 3.7?

I've just upgraded to 3.7 and one of the features in this release is the automatic application of security releases. However once I upgraded it said > "This site is not able to apply these updates automatically. But we’ll email > (my email address) when there is a new security release." What is it about my site that stops these updates being applied automatically?


Localise settings section headline

Assuming i've got a bunch of setting sections. I add these sections to my plugin page in the following way.               $sections = array('notifcations', 'updates');          foreach ($sections as $section)     {         add_settings_section(             $section .'_section',             $section,             array( $this, 'disable_callback_warnings' ),             'sgnc'         );     }      Everything works as expected but i wonder how to localise the section headline? As far as i know i can't pass any variables to the locale functions `_e()` and `__()`. So this won't work:               $sections = array('notifcations', 'updates');          foreach ($sections as $section)     {         add_settings_section(             $section .'_section',             __($section),             array( $this, 'disable_callback_warnings' ),             'sgnc'         );     }      http://codex.wordpress.org/Function_Reference/add_settings_section