Query posts by content lenght

I am using the code below to pull a random post of my site every 6 hour.               if ( false === ( $social_trans_post_id = get_transient( '$social_trans_post_id' ) ) ) {                     $args = array('numberposts' => 1, 'orderby' => 'rand');                     $social_trans = get_posts($args);                     set_transient('$social_trans_post_id', $social_trans[0]->ID, (60*60*6));                 } else {                     $args = array('post__in' => array($social_trans_post_id));                     $social_trans = get_posts($args);                 }      To integrate with Twitter, I'd like to only pull posts with 140 characters or less. I know about `<?php echo substr(($post->post_content), 0,140); ?>` which I am using already as a temporary solution. I tried to setup a condition and this is where I got stuck:               if ( false === ( $social_trans_post_id = get_transient( '$social_trans_post_id' ) ) ) {                     $args = array('numberposts' => 1, 'orderby' => 'rand');                     $social_trans = get_posts($args);                             if (strlen( $social_trans->post_content > 140 ) ) {                                // Pull another post?                              }                     set_transient('$social_trans_post_id', $social_trans[0]->ID, (60*60*6));                 } else {                     $args = array('post__in' => array($social_trans_post_id));                     $social_trans = get_posts($args);                 }


Do i need the git directory?

I have installed a wordpress site and for some reason I can see these 2 directories: .git .qidb Do I need them? Can I remove them? Will it hurt me in any way?


Automatically load Wordpress page on server every XX hours

I have a page in my Wordpress site that calculates post popularity and updates several meta fields on the posts and calls a few functions as well. This page is set to "Private" so that only myself and other admins can see it. Is there a way to load this page automatically every 6, 12, or 24 hours? I'd be satisfied with a plugin, but generally prefer to write my own PHP code.


Building a WP Shortcode: Loading Markers on a Google Map

I'm learning about plugins. I've built a basic Google Map plugin. But, I'm having problems putting markers on the map. I've pulled the lat long coordinates from a mySQL db. I'm following the Using PHP/MySQL with Google Maps tutorial. My problem is that the tutorial assumes that you can call the php file in a browser to check if its producing valid XML. I'm at the part with the heading "Using PHP's DOM functions to output XML". I'm not sure how to test whether the XML is created and being outputted correctly. In the part about loading the XML, they use GDownloadUrl("phpsqlajax_genxml.php", function(data). But, my PHP that builds the XML is part of the main plugin file, it's not in a separate php file. This is what I've got:               $dom = new DOMDocument('1.0');     $node = $dom->createElement('markers');     $parnode = $dom->appendChild($node);              $csf_data = $wpdb->get_results($wpdb->prepare("SELECT  * "));                               foreach($csf_data as $incident) {                 $node = $dom->createElement('marker');                 $newnode =  $parnode->appendChild($node);                 $newnode->setAttribute("lat", $incident->latitude);                 $newnode->setAttribute("lng", $incident->longitude);             }                  die();                  echo $dom->saveXML;        * a) How do I build the XML file in WordPress?    * b) How do I load the XML file in WordPress? Any suggestions? Thank you. * * * UPDATE: Google revised their tutorial. Please see this link. Thank you. * * * UPDATE 2: Making some progress. I figured out how to load a static XML file and place the markers on the map. Now, all I need to figure out is how to build an XML file from data pulled from the db in PHP in a WordPress plugin.


Filter all html output

I would like to make sure no email address is published in plain. So i developed a plugin that replace all email addresses by a spambot-safe alternative. But some users put their email address in their blog header, outside the post loop. How can i capture and filter that? This works:                       add_filter('the_content', array(&$this,"pep_replace"));             add_filter('the_excerpt', array(&$this,"pep_replace_excerpt"));             add_filter('the_comments', array(&$this,"pep_replace"));      This does not (it does not capture the email address i've added in my test theme header.php file).               add_filter('template',  array(&$this,"pep_replace"));     add_filter('wp_head',  array(&$this,"pep_replace"));     add_filter('shutdown',  array(&$this,"pep_replace"));      I'm digging into the hook documentation, but i'm out of ideas on what could be the right filter hook. Thank you for your time.


IF statement not falling over to ELSE with Options Framework

I am using the Options Framework to give the theme user the ability to upload their own background image. I have an image upload option with option ID = page_background. In header.php, I have:               <?php if (of_get_option('page_background', 'no entry')) { ?>     <style>     body {      background: url(<?php echo of_get_option('page_background', 'no entry');?>) no-repeat center center fixed;         -webkit-background-size: cover;         -moz-background-size: cover;         -o-background-size: cover;         background-size: cover;     }     </style>     <?php } else { ?>     <style>     body {      background: url(<?php echo get_template_directory_uri(); ?>/images/bodybg.jpg) no-repeat center center fixed;         -webkit-background-size: cover;         -moz-background-size: cover;         -o-background-size: cover;         background-size: cover;     }     </style>     <?php } ?>      At present, there is no background image uploaded, so the IF statement should return false, and proceed to the ELSE section, where a predefined background image is applied. However, the front end returns code: `background: url(no entry)` I use this exact same code on another theme and it works. Any ideas what is wrong with this theme?


Get a single post ID based on an exact match of 1 or more meta values

I'd like to find the post ID based on an exact match of meta values (could be more than 1). All the examples I have found show find the post ID from 1 meta value. In my example I'd like to pass in an array of values and find an exact match. Below is what I have so far, which can find the correct post ID but isn't an exact match. It returns the post ID if **any** of the values match in the array below. I need it to match **all** of the values.               // these values are dynamic, so multiple meta_query arrays are not an option     $array_of_values_to_match = array( '1', '2', '3' );          $args = array(         'post_type' => 'post',         'meta_query' => array(             array(                 'key' => '_some_meta_key', // they all have the same meta_key                 'value' => $array_of_values_to_match,                 'compare' => 'IN' // can't use = when passing in an array             ),         ),     );          $posts = get_posts( $args );      As per the codex, `Array support is limited to a compare value of 'IN', 'NOT IN', 'BETWEEN', or 'NOT BETWEEN'` So if my wp_postmeta table looked like the following, it should match list the post with the id of `122`               post_id   meta_key          meta_value     122       _some_meta_key    1     122       _some_meta_key    2     122       _some_meta_key    3      But **not** if it looked like this (there's no 3)               post_id   meta_key          meta_value     122       _some_meta_key    1     122       _some_meta_key    2     122       _some_meta_key    8


Echo the key from a select-box in Array with get_option (Settings API)

I'm trying to print a key from one select box. I'm using the WordPress Settings API. This is the array:               $options = array (     array(  "name" => "Styles & Fonts",             "type" => "title"),                 array(  "type" => "open"),                 array(  "name" => "Color scheme",                         "desc" => "Select the color scheme for the theme.",                         "type" => "select",                         "id" => "st_styles",                         "options" => array("style", "dark", "grey", "green", "red"),                         "std" => "style"),                 array(  "name" => "Loop style",                         "desc" => "Select the style loop for the theme.",                         "type" => "select",                         "id" => "st_loops",                         "options" => array('default' => 'Normal (default)', 'small' => 'No thumbnails', 'large' => 'Big thumbnails'),                         "std" => "style"),                 array(  "type" => "close"),     );      You can see 2 examples on this code, the first has the options in an array, and the second has the options in an **associative array**. I can get the value with this code:               echo get_option('st_styles', 'style')      If the selected option is 'dark', it prints 'dark'. By default it's 'style'. This works fine!! But in the second example I used an associative array because I want to show 'Normal (default)' in the select box; then I want to use 'default' (without spaces) as a CSS class. I tried:               echo get_option('st_loops', 'default')[key];     //It returns me the letter 'N'; the first of 'Normal (default)', I think.          print array_keys(get_option('st_loops', 'default'));     //Nothing.          echo get_option(array_keys('st_loops', 'default'));     //Nothing.      And finally I tried with this:               global $options;foreach ($options as $value) {         if (get_option( $value['id'] ) === FALSE) { $$value['id'] = $value['std']; } else { $$value['id'] = get_option( $value['id'] ); }         }              echo $st_loops;             //Prints 'Normal (default)'.         echo $st_loops[key];             //Prints 'N'.         echo $st_loops[$key];             //Prints 'N' again.         print array_keys($st_loops);             //Prints nothing.         echo key($st_loops);             //Prints nothing.      So I have no idea what to do about this. I'm sure it's easy but I'm being unlucky. **Updated 1:** This:               global $options;foreach ($options as $value) {      if (get_option( $value['id'] ) === FALSE) { $$value['id'] = $value['std']; } else { $$value['id'] = get_option( $value['id'] ); }     }     print_r($options);      returns this:               [29] => Array         (             [name] => Loop style             [desc] => Select the style loop for the theme.             [type] => select             [id] => st_loops             [options] => Array                 (                     [default] => Normal (default)                     [small] => No thumbnails                     [large] => Big thumbnails                 )                  [std] => style         )      **Updated 3:** At the moment, this is the code as provisional solution:               $loop_class = get_option('st_loops');     if($loop_class == "Normal (default)") { $loop_class = "default"; }     elseif($loop_class == "No thumbnails") { $loop_class = "small"; }     elseif($loop_class == "Big thumbnails") { $loop_class = "large"; }     echo $loop_class;      Easiest way, but too many lines, I think.


How to get custom post types to play nice with schema.org (aka how to wrap the contents in the schema.org markup)?

Building a Culinary site with a Custom Post Type like "Recipes". I'm fixing to wrap the content of the said post type in schema.org's recipe microformat. How do I achieve this ?


Why does WP_Query show only the same post even with different categories and endwhile?

I have 3 divs that WP_Query with 3 different categories and end it with the php endwhile,but it only shows the same most recent post query three times over. Do I need to hard reset the query loop somehow? I'm looking to see where to put wp_reset_postdata...
         <?php $test = new WP_Query('category=[errands]&showposts=1');         while ($test->have_posts()) : $test->the_post(); ?>
<?php the_title(); ?>
         <img src="<?php bloginfo('template_directory'); ?>/images/errands.jpg" />                  <?php the_content(__('Read more'));?>             <?php endwhile;?>             <?php wp_reset_postdata(); ?>

         <?php $test2 = new WP_Query('category=[shopping]&showposts=1');         while ($test2->have_posts()) : $test2->the_post(); ?>
<?php the_title(); ?>
         <img src="<?php bloginfo('template_directory'); ?>/images/shopping.jpg" />                  <?php the_content(__('Read more'));?>             <?php endwhile;?>             <?php wp_reset_postdata(); ?>

         <?php $test3 = new WP_Query('category=[calendar_maintenance]&showposts=1');         while ($test3->have_posts()) : $test3->the_post(); ?>
<?php the_title(); ?>
         <img src="<?php bloginfo('template_directory'); ?>/images/calendar.jpg" />                  <?php the_content(__('Read more'));?>             <?php endwhile;?>             <?php wp_reset_postdata(); ?>


How do I use "if field exists" with $curauth?

I've added some extra $curauth fields to the user profile page via ths method:               function change_contactmethod( $contactmethods ) {          $contactmethods['twitter'] = 'Twitter URL';          // more $contactmethods go here          return $contactmethods;      }          add_filter('user_contactmethods','change_contactmethod',10,1);      And they are displayed this way on the author.php template, which only displays the link if it is entered in te user profile: `<?php echo $curauth->twitter; ?>` But what I need to do is determine if the curauth field exists before display, as I want to turn the twitter URL into a linked image. Calling $curauth->twitter; as above with a linked image still displays the image if no link is entered in the users profile. This is what I'm trying with no luck:               <?php $my_post_meta = get_post_meta($post->ID, 'twitter', true);     if ( ! empty ( $my_post_meta ) )         echo '<img src="<?php bloginfo(\'template_url\'); ?>/images/twitter.png">'; ?>      **Update 12/23/11 - This now works:**               <?php if ( !empty( $curauth->twitter ) ) { echo 'twitter . '">'; } ?>


How to check if a WP_Query has data

I have the following WP_Query, which works great:
Frequently Asked Questions

          <?php          $args = array(         'post_type' => 'questions',         'posts_per_page' => '3',                                                 'tax_query' => array(             array(             'taxonomy' => 'types',             'field' => 'slug',             'terms' => 'customer-service'             )         )     );          $loop = new WP_Query( $args );     while ( $loop->have_posts() ) : $loop->the_post(); ?>
<a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_title(); ?>
     <?php endwhile; ?>
      As you can see, there's a title on the top of the query and I would like to find a way to only show that title if there are values inside the query. If not, in case there are no questions, the title still shows and it looks weird. Any ideas how can I check if there are values inside a query or not? Thanks!


What questions do you ask when asked to give an estimate on theme development?

I just recieved an email that asked the following question: "How much will cost to code a WordPress theme?" I cannot answer this question without know the answer to a plethora of other questions. I cam up with the following off the top of my head:   1. What browsers/devices need to be supported?   2. What core WordPress functionality needs to be supported?   3. What template files need to be created?   4. Are there and custom page templates?   5. Is the theme to be internationalized?   6. Does the theme offer functionality outside the scope of WordPress core?   7. How complex is the design?   8. What level of accessibility is expected?   9. How much of WordPress functionality is represented in the PSD? Unfortunately, I do not have all of these written down anywhere and I'm sure that I am missing very important things. To save me time in the future as well as to help other freelancers, I thought it might be a good idea for everyone to list the questions they ask potential clients when asked to develop a theme from an unknown design.


Converting an existing query_posts to WP_Query

I am having trouble trying to convert my query_posts loop that is bugging out to a WP_Query, was hoping someone may have some luck looking at it: This is my old loop:
                      <?php                   query_posts(array( 'post_type' => 'work', 'taxonomy' => 'type', 'posts_per_page' => '-1', 'orderby' => 'title', 'order' => 'ASC' ));                   if ( have_posts() ) : while ( have_posts() ) : the_post();                 ?>                          <aside class="work_item" data-id="id-<?php the_id(); ?>" data-type="<?php $posttags = get_the_tags(); if ($posttags) { foreach ($posttags as $tag) { echo str_replace('-','_',$tag->slug . ' '); } } ?> <?php $posttags = get_the_terms($post->ID, 'type'); if ($posttags) { foreach($posttags as $tag) { echo str_replace('-','_',$tag->slug . ''); } } ?>">

                                     <?php echo get_the_post_thumbnail($post_id, 'Work Gallery', array('class' => 'lazy',)); ?>

<a href="<?php the_permalink(); ?>"><?php the_title(); ?>
                                          <?php if ( 'work' == get_post_type() && has_term( 'case-study', 'type') ) { // show 25 characters from the content if the post is a case study ?>
<?php the_excerpt(25); ?>
                                          <?php } else { ?>                                          <?php if ( 'work' == get_post_type() && has_term( 'portfolio', 'type') ) { // if the post is a portfolio item show the DESCRIPTION of the image ?>
<?php echo get_post(get_post_thumbnail_id())->post_content; ?>
                                          <?php } } ?>                                          <?php                                         if( has_tag() ) {                                             // IF THE POST HAS TAGS                                             the_tags('
', '.

', '.
');                                             //$articletags = strip_tags(get_the_tag_list('',', ','')); echo $articletags;                                         }                                         else {                                             // IF NO TAGS                                         }                                     ?>

<a class="tooltip" title="full details" href="<?php echo the_permalink(); ?>">View All

<a rel="prettyPhoto[mixed]" class="expanded tooltip" title="preview" href="#prettyPhoto-<?php the_id(); ?>">Expand

                                         <?php if (has_post_thumbnail( $post->ID ) ): ?>                                         <?php $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full' ); ?>                                             <a class="work_lb tooltip" title="view in lightbox" href="<?php echo $image[0]; ?>" rel="prettyPhoto">Lightbox                                         <?php endif; ?>

                                  <aside class="work_expanded" id="prettyPhoto-<?php the_id(); ?>">                                      <?php the_title('
', '
'); ?>                                                                                <?php                                         $images = get_field('gallery');                                         if( $images ):                                     ?>

                                                 <?php foreach( $images as $image ): ?>
                                                         <img class="lazy" src="<?php echo $image['sizes']['Portfolio 1200']; ?>" alt="<?php echo $image['alt']; ?>" />
<?php echo $image['caption']; ?>

                                                 <?php endforeach; ?>

                                     <?php endif; ?>                                                                                <?php get_template_part( 'sidebar', 'work' ); ?>
                                              <?php the_content(); ?>
                                                                                <?php endwhile; endif; wp_reset_postdata(); ?>
      My attempted new loop:
                      <?php                     $all_work = new WP_Query(array( 'post_type' => 'work', 'tax_query' => array(array('taxonomy' => 'type', 'field' => 'slug', 'terms' => array( 'case study', 'portfolio' ) ) ), 'posts_per_page' => '-1', 'post_status' => 'publish', 'orderby' => 'title', 'order' => 'ASC' ) );                     while ( $all_work->have_posts() ) : $all_work->the_post();                 ?>                               <aside class="work_item" data-id="id-<?php the_id(); ?>" data-type="<?php $posttags = get_the_tags(); if ($posttags) { foreach ($posttags as $tag) { echo str_replace('-','_',$tag->slug . ' '); } } ?> <?php $posttags = get_the_terms($post->ID, 'type'); if ($posttags) { foreach($posttags as $tag) { echo str_replace('-','_',$tag->slug . ''); } } ?>">

                                     <?php echo get_the_post_thumbnail($post_id, 'Work Gallery', array('class' => 'lazy',)); ?>

<a href="<?php the_permalink(); ?>"><?php the_title(); ?>
                                          <?php if ( 'work' == get_post_type() && has_term( 'case-study', 'type') ) { // show 25 characters from the content if the post is a case study ?>
<?php the_excerpt(25); ?>
                                          <?php } else { ?>                                          <?php if ( 'work' == get_post_type() && has_term( 'portfolio', 'type') ) { // if the post is a portfolio item show the DESCRIPTION of the image ?>
<?php echo get_post(get_post_thumbnail_id())->post_content; ?>
                                          <?php } } ?>                                          <?php                                         if( has_tag() ) {                                             // IF THE POST HAS TAGS                                             the_tags('
', '.

', '.
');                                             //$articletags = strip_tags(get_the_tag_list('',', ','')); echo $articletags;                                         }                                         else {                                             // IF NO TAGS                                         }                                     ?>

<a class="tooltip" title="full details" href="<?php echo the_permalink(); ?>">View All

<a rel="prettyPhoto[mixed]" class="expanded tooltip" title="preview" href="#prettyPhoto-<?php the_id(); ?>">Expand

                                         <?php if (has_post_thumbnail( $post->ID ) ): ?>                                         <?php $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full' ); ?>                                             <a class="work_lb tooltip" title="view in lightbox" href="<?php echo $image[0]; ?>" rel="prettyPhoto">Lightbox                                         <?php endif; ?>

                                  <aside class="work_expanded" id="prettyPhoto-<?php the_id(); ?>">                                      <?php the_title('
', '
'); ?>                                                                                <?php                                         $images = get_field('gallery');                                         if( $images ):                                     ?>

                                                 <?php foreach( $images as $image ): ?>
                                                         <img class="lazy" src="<?php echo $image['sizes']['Portfolio 1200']; ?>" alt="<?php echo $image['alt']; ?>" />
<?php echo $image['caption']; ?>

                                                 <?php endforeach; ?>

                                     <?php endif; ?>                                                                                <?php get_template_part( 'sidebar', 'work' ); ?>
                                              <?php the_content(); ?>
                                                                                <?php endwhile; wp_reset_postdata(); ?>
      Not sure what I am missing but its not working. When I try to reload the page it just draws a blank... but I am not seeing anything in my error log either. Thanks for any input!


Changing name of sidebar widget

I have created dynamic sidebars. They are working fine and appear in the Widgets area. However, I would like to customize the name that appears on each sidebar. So, right now each sidebar is named "Sidebar 1", "Sidebar 2", etc. Instead, I would like them to say something like "About Sidebar", "Toolkit Sidebar". This is not the title (that field is blank and the user can enter whatever text they please). Thank you for any help! Jeff I am not sure how to do that.


Internal error (500) on local & Fatal error on live when trying to access post type edit screen

I'm building a CMS for a company that has 60,000+ static pages which have been converted into posts. 30,000 of these are a particular post type. When I try to access the edit screen in the admin area (http://www.mysite.com/wp- admin/edit.php?post_type=post-type. On my local server I get an internal 500 error. On my live site, (database migrated with wp-migrate-db-pro) i get: Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 71 bytes) in /home/omol/public_html/wp-includes/post.php on line 1876 seems like 256m should be enough memory? I wasn't having this error before and was able to see the 30,000 articles on the edit screen just yesterday. I've reverted to twenty-twelve theme & checked the htaccess, to no avail.


A single instance of WooCommerce with multilanguage on mapped domains?

I'm tinkering with the following scenario which includes WordPress, bbPress, BuddyPress and WooCommerce. My understanding is that currently WooCommerce does not support multisite. If one goes multisite, one gets a separate instance of WooCommerce for each site in the network. But this is troublesome, there would be no syncing of stock, price updates, sales, etc. Suppose though that my purpose is not having multisite, but **multilingual**. I need the same content of my main site translated but I need a different domain for each locale. And this multilingual setup should have only with one instance of WooCommerce. How do I achieve a setup where:   1. I have a **single instance** of WordPress, BuddyPress, bbPress and WooCommerce   2. I want to **translate** this instance in multiple languages    3. each language gets its **own domain** (not subdomain)   4. **content** that is not translated just does not appear in domains where the translation is missing   5. I can **translate permalinks** according to language (silly example: if I have a post-type called "horse" in the English site, the _post type archive_ would be `englishdomain.com/horse/` but can I get `spanishdomain.com/caballo/` for Spanish? and the same logic for single posts and everything else. Is that even possible? What solutions could I use? If it's impossible or cumbersome to achieve, do you have an alternative approach to suggest? The most important points is to have centralized shop and users, but different domain per language (possibly with localized permalinks). Thanks!


Modifying previous_posts link to use AJAX

I am editing the `wp-includes/link-template.php` file in Wordpress, and would like to use Ajax to load posts into my ID of `#box-right`. I am aware that there are many plugins for this usage but I am using my own HTML and CSS layout, and including posts (not having integrated my site with WordPress). I am using AJAX to load content in certain DIV's within my site, I need to change the following code to load posts into my box-right div.               return '". preg_replace( '/&([^#])(?![a-z]{1,8};)/i', '&$1', $label ) .'';      The AJAX link looks like this:                     I need to make the top link load the AJAX, I thought it would look like this (I am new to PHP).               return '$attr>". preg_replace( '/&([^#])(?![a-z]{1,8};)/i', '&$1', $label ) .'';      What am I doing wrong here?


Regex For Extracting First 4 letters of search term

I am using a redirection plugin and want to redirect the existing search url `http://www.example.com/search/abcdef` to `http://www.example.com/?s=abcd` I am able to redirect `/search/abcdef` to `/?s=abcdef` however I can't get hold of how to trim and use the first of characters of search term i.e `abcd` in short it should look like `/?s=abcd` As of now I am using following regex with plugin: Source URL - `/search/(.*)` Target URL - `http://www.example.com/?s=$1` I'd appreciate any pointers in that direction or maybe a working answer ;)


Is the Block Bad Queries Plugin Still Relevant?

The Block Bad Queries Plugin hasn't been updated recently. Is WordPress still subject to these types of malicious attacks or has it been hardened sufficiently to make the plugin obsolete? Is there an alternative?


About WP's save_post action

Quick question, in API's some times `save_post` is used(most of the time actually). Is `save_post` the equivalent of the query action `INSERT INTO` whereas `save_post` saves metadata and forces Wordpress to do the rest of the work when used correctly? Thanks in advance!


Shortcode inside <a><span> WP wraps in in a <p> and shortcode is done after

I want to do this:               [shortcode]      The Shortcode should be disabled but linked to a loginform. but wordpress does this:                [shortcode]          The crazy thing is It worked a few days ago... If you look here: http://www.manugoo.com/beta/kaninchenrasierer-4/ the "mitmachen" button is the shortcode and should link to loginform _EDIT_ After playing with some functions.php codes I found somewhere this is the output:

     Mitmachen!      I tried to insert other shortcodes which has no a-tag inside. Same result.


How to setup a Custom Taxonomy Term template

I have a Custom Post Type and 2 taxonomies attached to it. Each taxonomy has about 20 terms containing several posts. While I have successfully setup a custom archive template for my custom-post-type. My Taxonomy terms are creating problem. When I view any of the terms page (by clicking them from CPT menu) it shows me the titles of the posts under it. I tried setting up taxonomy-my-taxonomy-my-term.php but the page does not pick it up. Instead it is using archive template. Here is the body class that is returned: archive tax-path term-a-path term-19 logged-in Which template do I need to make in order to list all posts under a specific term, and can I have a generic template for all terms, since all of them have posts with similar data fields.


How to change the full capitals font title of my WordPress Blog?

I would like to show my WordPress blog's title as "Dummit foote 4.2.4". But I am getting all capitals as "DUMMIT FOOTE 4.2.4" What should I do to change this? I do not see any editor case in my dashboard. ![enter image description here](http://i.stack.imgur.com/gX9wU.png) It was mentioned that i should change something in .css but i do not even know where to find that.


Issues with post_content when using wp_insert_post

I have a very weird problem and I would really appreciate your help with it. I am using wp_insert_post when a user submits a post. It works fine when I submit the form (i.e. the admin of the wordpress site), but when I try the same thing with a different user (i.e. different email, not the admin of the wordpress site), it only shows part of the content I used in the post_content field. my code:               $my_post = array(     'post_title'    => 'My bet',     'post_content'  => '<form action="" method="post" id=form_id>' . 'bet ID: ' . '<input readonly id=betid     type=text value=' . $bet_id . '>' . '<input id=url name=urlpath type=hidden value=>' . '</form>' ."\r\n match: " . '' . $_POST[event] . '' . "\r\n" . $current_user->user_login . "'s Pick: " . $_POST[bet] . '' . '' . '' ."\r\n Amount: " . '' . $_POST[amount] . '' . "<?php include('wp-content/themes/twentyfourteen/test.php') ?>"     'post_status'   => 'publish');      When it is executed for the wordpress admin user (user ID=1) it works fine. when it is executed for any other user (user ID!=1) it is not showing the input fields of the form, and more important, not including the test.php I have included.


How to cache posts based on $_GET? Option name is too long? Options / transients

I have a search feature set up that is fairly expensive and I want to cache the results, based on the $_get string, like: `?search_type=product&relation=or&date=all&s=tagsearch&merchcat=cotton&brand=brandx&color=blue&etc=morestuff` So, i'm trying to cache the array of posts that I get:               if (false === ( $products = get_transient($name) ) ) {         $products = getproducts();         set_transient($name, $products, 60*60*12);     }      for the transient name, I've been trying various things like               $name= base64_encode(serialize($_GET));      But, I'm running into the problem of the option name getting truncated and possibly encoded, slashed, etc. How would you go about solving this?


Dev, Stage and Production Deployment for WordPress Sites?

So I need to be able to have dev/stage/production iterations (over separate servers) for a WordPress website, I use git usually but this obviously isn't going to work with WordPress sites because of the reliance on the database for the main configuration of... well, almost everything. So my question is how do you guys do it? I had a quick Google and saw that there was a few plugins, is this the only way? Which ones do the job the best in terms of ease of use, speed, reliability, ui etc.?


pull custom fields values from wp-database in a nested foreach loop

I am trying to display custom fields on my template values of which i am pulling from postmeta table doing something wrong with a loop or not writing the foreach args correctly not sure whats the problem pastebin link for the code http://pastebin.com/eyPD6Qws basically i want to display 15 div's with 3 cols so to say (name, photo,region) To make it more simple to explain exactly what i am doing is using a plugin called flutter(yes i know it is dead now) but it works for me i am creating profiles for say agents there individual pages work perfectly but now i want to create a page where i display small brief of everyone's profile (like we have portfolio pages) for which i have created a code(which can be seen here http://pastebin.com/eyPD6Qws)


How to display more than one instance for a widget?

I'm using a plugin called Recent category post widget. Unfortunately the plugin developer is no longer offering support. The way this plugin is coded, displays only one instance of the widget (meaning that I can use this widget only once). What must be changed in the code below so as to use multiple instances of the widget?               <?php     register_activation_hook    (   __FILE__,           array('single_category_posts_widget', 'activate')       );     register_deactivation_hook  (   __FILE__,           array('single_category_posts_widget', 'deactivate')     );     add_action                  (   "widgets_init",     array('single_category_posts_widget', 'register')       );          class single_category_posts_widget {              function activate()         {             if( get_option( 'single_category_posts_widget_title' ) === FALSE ) {                 update_option( 'single_category_posts_widget_title', 'Recent Category Posts' );             }             if( get_option( 'single_category_posts_widget_category' ) === FALSE ) {                 update_option( 'single_category_posts_widget_category', 0 );             }             if( get_option( 'single_category_posts_widget_qty' ) === FALSE ) {                 update_option( 'single_category_posts_widget_qty', 5 );             }         }              function deactivate()         {             delete_option( 'single_category_posts_widget_title' );             delete_option( 'single_category_posts_widget_category' );             delete_option( 'single_category_posts_widget_qty' );         }              function register()         {             wp_register_sidebar_widget( 'recent-category-posts', 'Recent Posts in Category', array('single_category_posts_widget', 'widget' ));             wp_register_widget_control( 'recent-category-posts', 'Recent Posts in Category', array('single_category_posts_widget', 'control' ));         }              function control()         {             if (isset($_POST['single_category_posts_widget_title']))        update_option(  'single_category_posts_widget_title',       mysql_real_escape_string($_POST['single_category_posts_widget_title'])      );             if (isset($_POST['single_category_posts_widget_category']))     update_option(  'single_category_posts_widget_category',    intval($_POST['single_category_posts_widget_category']) );             if (isset($_POST['single_category_posts_widget_qty']))          update_option(  'single_category_posts_widget_qty',         intval($_POST['single_category_posts_widget_qty'])      );             ?>
                 Widget Title:
                 <input class="widefat" type="text" name="single_category_posts_widget_title" value="<?php echo get_option( 'single_category_posts_widget_title' ); ?>" />

                 What Category:
                 <?php wp_dropdown_categories( Array(                             'orderby'            => 'ID',                              'order'              => 'ASC',                             'show_count'         => 1,                             'hide_empty'         => 0,                             'hide_if_empty'      => false,                             'echo'               => 1,                             'selected'           => get_option( 'single_category_posts_widget_category' ),                             'hierarchical'       => 1,                              'name'               => 'single_category_posts_widget_category',                             'id'                 => 'single_category_posts_widget_category',                             'class'              => 'widefat',                             'taxonomy'           => 'category',                         ) ); ?>

                 How Many Posts:
                 <input class="widefat" type="text" name="single_category_posts_widget_qty" value="<?php echo get_option( 'single_category_posts_widget_qty' ); ?>" />
             <?php         }              function widget( $args )         {             echo $args['before_widget'];             echo $args['before_title'] . get_option( 'single_category_posts_widget_title', 'Recent Category Posts' ) . $args['after_title'];             echo self::get_cat_posts( get_option( 'single_category_posts_widget_category', 0 ), get_option( 'single_category_posts_widget_qty', 5 ) );             echo $args['after_widget'];         }              function get_cat_posts( $cat, $qty )         {             $posts = get_posts( Array(                 'cat'           =>  $cat,                 'orderby'       =>  'date',                 'order'         =>  'DESC',                 'numberposts'   =>  $qty             ));             $returnThis = '';             if( count( $posts ) )                 $returnThis .= '
'."\r\n";             foreach( $posts as $post )                 $returnThis .= "\t".'
ID ).'">'.$post->post_title.'
'."\r\n";             if( count( $posts ) )                 $returnThis .= '
'."\r\n";             return $returnThis;         }          }


Where can I learn to create my own theme?

I want to learn how to create a theme for WordPress. Where can I find information and resources on how to do it?


I want to have my custom field use HTML, how do I do that?

I want to have my custom field use HTML, how do I do that in such a way that I can use a rich text editor to view the content?


wp-admin seems to be redirecting

I'm having a strange problem with my w-admin login. This has only started since I upgraded to 3.0 When I go to wp-admin, the login form appears as normal, but when I enter my username and pass, I am presented with the login form again every time. Using the password recovery feature results in an email not found error. I know the username password and email are correct, b/c I have access to the mysql database and I can see the values (at least the user name and email). Anyone have any ideas of what could be going wrong?


Is it possible to override this function/class in a child theme?

Is it possible to override this `widget` function from a parent theme? I saw this blog, but it dealt with a simpler case. http://venutip.com/content/right-way-override-theme-functions ### parent               class Chocolat_Widget_New_Entrys extends WP_Widget {            function __construct() {...            function widget( $args, $instance ) {...     }     add_action( 'widgets_init', create_function( '', 'return register_widget( "Chocolat_Widget_New_Entrys" );' ) );      I attempted to use `remove_action('widgets_init','???');` but soon realized I could not get a handle on the function that registered it! I thought about overriding the function and creating a subclass, but still, it is registered in the parent by the name of the parent class. I thought about just copying the whole class, but child `functions.php` is loaded before `parents.php`.


Custom post type post taxonomies

I created simple custom post type with few taxonomies. I               <?php $query_params = getQueryParams(); $query_params['post_type'] = 'client';          if(isset($query_params['search'])){             $query_params['post_title_like'] = $query_params['search'];             unset($query_params['search']);         }         $loop = new WP_Query($query_params);         if($loop->have_posts()) : while($loop->have_posts()): $loop->the_post();               // SOME HTML              endwhile; endif; ?>      Then I tried to list display taxonomies for each post, by this:               $categories = get_categories("taxonomy=city");          foreach ($categories as $category) :          echo '<li>' . $category->name . '</li>';          endforeach;      But I always get all created taxonomies, not only selected to post. Any suggestions?


Unable to select an old date in wordpress

I am unable to set the year below 1899 for a post. If i set year below 1899 it is set to the current year automatically. ![screen shot](http://i.stack.imgur.com/IC73X.gif) I have purchased the _Timeline_ theme and asked in their support forum. They replied: > This sounds like a limitation created by your hosting provider. Nothing in > the theme is preventing the date you assign – as you can see, the demo has > posts using dates in the 1400s. Try contacting your hosting provider and see > if they have any insight on how to address that.


customizing recent posts

Im working on my first wordpress blog and trying to avoid plugins if at all possible for a lot of what doesn't really need to have a plugin. I am slightly familiar with php ( I don't understand it but I know where to put it and what file should go where). I understand the how to change the theme files around, CSS & HTML. So if I can do it with some practice and time I'd rather hand code it then use a plugin. I'm trying to style my home page sidebar's recent posts and I'm not finding that hard at all, but I'm not sure how to get images into the recent posts. I have an image in each of my posts and now I'm just trying to get a small thumbnail view of the first image into my "RECENT BLOGS" area on my homepage. ![enter image description here](http://i.stack.imgur.com/DyzRv.png) Like in my design, here. Does anyone have a method or snippet of code that would work for what I'm trying to do? @Tom: This is what my code looks like after placing your suggestion in
<?php _e( 'Recent Blogs', 'toolbox' ); ?>

             <?php             if(has_post_thumbnail()) {                 the_post_thumbnail();             } else {                 // show a default image if no featured image is specified                 echo '';             }             ?>
         <?php             $args = array( 'numberposts' => '3' );             $recent_posts = wp_get_recent_posts( $args );                 foreach( $recent_posts as $recent ){             echo '
' .   $recent["post_title"].'
 ';          }         ?>           I have made it point to a default image but that's not even showing up. My image is styled               .thumbnail { width: 50px; height: 50px; border: 1px solid #093; padding: 5px;}      And this is the site you can find my sidebar problem at So I'm not sure what I'm doing wrong..


Incremental number handling on duplicate file names

After a couple of hours searching the WP core I've lost hope finding this myself (for once). Could someone guide me perhaps to where WordPress handles the incremental number when having duplicate file names during uploading? As a side question. When handling questions like this, where and how would you start searching? AFAIK I've searched through every file containing `file` and `upload`.


Pagination on custom query

I'm using the following code with `query_posts` to put together a custom search:               $args = array(         'post_type' => 'species',         'meta_query' => $meta_query,         'tax_query' => $tax_query     );      `$meta_query` is put together with a few segments of code like this:               if (!empty($_POST["s_aquarium_H"])) {         $val = convert_values('size', $size, $_POST["s_aquarium_H"]);         $aquarium_H = array(             'key' => 'aquarium_H',             'value' => $val,             'type' => 'numeric',             'compare' => '<='         );         $meta_query[] = $aquarium_H;     }      This works perfectly well and is accessed by visiting `/advanced-search/`. However, my pagination does not. When you click `Next Entries`, the URL changes to `/advanced-search/page/2/` but simply re-opens the Advanced Search form. I guess this is because I'm using `$_POST`. Is there a way of using pagination with `$_POST` or do I need to change my code to `get_query_var` or something? * * * **EDIT** My rewrite rules appear to be correct: `/advanced-search/page/2/` displays `pagename: advanced-search, paged: 2` in Monkeyman's Rewrite Analyzer plugin. ![Rewrite Rules](http://i.stack.imgur.com/PfY3i.png) * * * **FURTHER EDIT** My `advanced-search.php` page uses the following code to determine whether it should show the search form or the results. I guess this needs re-writing if I'm to use pagination:               <?php if ( isset( $_POST["act"] ) && $_POST["act"] == "s" ) : ?>      Does anyone have any ideas as to how I could go about rewriting this? I guess `GET` instead of `POST` needs to be used? * * * Thanks in advance,


2 localizations inside a WordPress theme

I'm building a theme which includes a separate "section" and I want to make both the theme and the separate section localizable. However, I don't want to have them under the same textdomain. Would someone advise against doing this? Could there be any issues? I don't want to have the separate section as a plugin. This is what could appear inside e.g. `functions.php`:               __('String', 'themename');     __('Another string', 'somethingelse');


WordPress Active and Development server best practices

I currently have a separate WordPress install on a subfolder /dev and the live site in the root directory. I developed the site on the dev folder and then copied it over when it was complete. I want to maintain the dev site for future enhancement testing. Is there a better or easier way to do this using built in WordPress features like multisite? Can anyone verify that this is a good way to approach it?


Limiting query_posts to 1, regardless of sticky post?

As part of my homepage template, using the standard query_posts I'm pulling out 1 post (styled using a different content_part), then an ad, then the rest of the posts. This works fine, except for when someone sets a post as sticky, when the loop with a posts_per_page set to 1, pulls out 2. How can I get his loop to only ever show 1 post, either the latest, OR the top sticky, but not both (which I understand is the expected behaviour)? Currently I have:                   <?php      $posts_per_page = get_option('posts_per_page');     $num_featured_posts = 1;          query_posts(array('posts_per_page' => $num_featured_posts)); ?>            <?php if ( have_posts() ) : ?>              <?php while ( have_posts() ) : the_post(); ?>                <?php get_template_part( 'content', 'super' ); ?>              <?php endwhile; ?>            <?php elseif ( current_user_can( 'edit_posts' ) ) : ?>              <?php get_template_part( 'no-results', 'index' ); ?>            <?php endif; ?>      Thanks, **UPDATE:** After explicitly calling out out only 1 post, regardless of sticky statuses, and exclusing that from the main loop of posts, my main loop now duplicates a post on subsequent pages (last one becomes first on page 2). Offset is causing me headaches and generally breaks pagination easily - is there another way to fix/add to this:                 wp_reset_query();       $args = array(         'post__not_in' => array($first_sticky_post),         'paged' => ( get_query_var('paged') ? get_query_var('paged') : 1 ),               );       //query_posts( $args );       $main_loop = new WP_Query( $args );      ... to reset where the loop should start on pages > 1? You can see it in action here: n2.project14.co.uk Thanks,


help in magento with wordpress function

I am new to magento and what i have magento wordpress by figpig installed.After much research i found that wordpress functions won't work in magento. As my function was placed in theme folder, which would display thumbnails in rss as well as turn hyperlinks in post. As i am new to magento, i want to convert the following function to make it work and where to use it? I already have it wordpress function.                   add_filter( 'the_excerpt_rss', 'insert_thumbnail_into_feed' );     add_filter( 'the_content_feed', 'insert_thumbnail_into_feed' );               function insert_thumbnail_into_feed() {         global $post;         if ( has_post_thumbnail( $post->ID ) ){             // replace thumbnail with yours             $content = '
' .get_the_post_thumbnail( $post->ID, 'thumbnail' ) .'
';         }              // get post content and replace feed content with         // you can also limit/filter the content to exclude shortcodes and html code etc.         $content .= '
' .get_the_content() .'
';              return $content;     }      also if someone can point me in right direction to learn about magento development wise.


delete category name in the pages

I'm looking for a way so that I can delete category's name in the pages. I tried to find something for category in index.php but I couldn't find anything. Please help me to solve this problem. Thanks in advance


Testing for post title in 'if/else' statement returns no content

I'm testing for a certain fixed post on an about page, I guessed that the best way is to test for post title (?). Here's my code, what's going wrong?               <?php     if (is_page()) {       $cat=get_cat_ID($post->post_title);       $posts = get_posts ("cat=$cat&showposts=35");            if ($posts) {         foreach ($posts as $post):           setup_postdata($post); ?>

<?php the_title(); ?>

          <?php    if ($post->post_title('skillset')) {                 echo '
';                     the_content('');                 echo '
';          }             else{             the_content('');             }                     endforeach;       }     }     ?>


get_template_directory_uri does not seem to work when defining WP_CONTENT_DIR

I have defined in my config:               define( 'WP_CONTENT_DIR', dirname(__FILE__) . '/somedirectory' );      after Codex: Editing WP Config BUT `<?php echo get_template_directory_uri(); ?>` prints out:                 http://dev.domain.com/wp-content/themes/mytheme      Even though it should print out               http://dev.domain.com/somedirectory/themes/mytheme      Has anyone else experienced this or know of a fix?


Publishing videos and images from blog to facebook

Is there any wordpress plugin for publishing videos and images from blog to respected facebook user's profile wall? I have a wordpress blog and having 1000+ users. these users will upload images and videos from wp-admin. These uploaded images and videos should be published to their respected facebook user's profile wall. Please help me if any solution....Thanks in advance.


Custom Menu echo own HTML

I've registered a custom menu and got all that set up, however the formatting of the HTML that the menu uses doesn't fit with the CSS/HTML menus I had previously and want to keep. Therefore I was wondering If there was a way to use the custom menu but `echo` your own HTML code for the menus. WordPress Generated HTML:

                 Home

                 About

                         What we do

                         Who we are

      My Custom HTML:

                   <img src="<?php echo get_template_directory_uri(); ?>/assets/drawing-pin.png">

Products

                   <img src="<?php echo get_template_directory_uri(); ?>/assets/corner-flick-cyan.png">

Products 1

Products 2


WP_Query on custom post type not displaying, multiple loops & get_template_part

I'm having problems getting my testimonials to display. On page.php I have a testimonials section. So I have a loop that grabs the content for page.php, and then a get_template_part('content', 'testimonials') to get the testimonial loop.
              <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<?php the_title(); ?>

<?php the_content(); ?>

              <?php endwhile; else : ?>
There were no posts :(
              <?php endif; ?>
          <?php get_template_part( 'content', 'testimonials' ); ?>      So my main loop is up there and looks like that above ^^. My testimonials loop looks like this below in content-testimonials.php:               <?php               $args = array(             'post_type' => 'testimonials',             'posts_per_page' => 1,             'orderby' => 'rand'         );              $the_query = new WP_Query( $args );          ?>          <?php if ( have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); ?>

“<?php the_field( 'testimonial' ); ?>”
             —<?php the_field( 'name' ); ?>
          <?php endwhile; else : ?>
There were no testimonials :(
          <?php endif; ?>      I'm still quite new to Wordpress, so I can't see what I'm missing, I've been through the admin area and made sure there were testimonials, edited the custom field to display if the post type is equal to testimonial, I just can't see why it wouldn't load. I look forward to your responses, thanks in advance!


Top menu disapears in Category Pages when filtering using ACF

I am using ACF (Advanced Custom Fields) and filtering the results using the method they posted on their website. http://www.advancedcustomfields.com/resources/tutorials/creating-wp-archive- custom-field-filter/ Filtering works fine, however, top menu disappears when the result is displayed. The code I am using is below: In functions.php add_action('pre_get_posts', 'my_pre_get_posts'); function my_pre_get_posts( $query ) { // validate if( is_admin() ) { return; }               // get original meta query     $meta_query = $query->get('meta_query');              // allow the url to alter the query         // eg: http://www.website.com/events?location=melbourne         // eg: http://www.website.com/events?location=sydney         if( !empty($_GET['bedrooms']) )         {             $bedrooms = explode(',', $_GET['bedrooms']);                  //Add our meta query to the original meta queries             $meta_query[] = array(                 'key'       => 'bedrooms',                 'value'     => $bedrooms,                 'compare'   => 'IN',             );         }          // update the meta query args     $query->set('meta_query', $meta_query);          // always return     return;      }      In category.php
         <?php               $field = get_field_object('bedrooms');         $values = explode(',', $_GET['bedrooms']);              ?>
             <?php foreach( $field['choices'] as $choice_value => $choice_label ): ?>
                     <input type="checkbox" value="<?php echo $choice_value; ?>" <?php if( in_array($choice_value, $values) ): ?>checked="checked"<?php endif; ?> /> <?php echo $choice_label; ?>

             <?php endforeach; ?>

           Demo: http://thepursesociety.com/_web/category/houses


show title if one of post meta exist

I have 4 metabox `facebook`, `twitter`, `instagram`, `youtube` with title "Follow Us". I am using this code to show facebook logo and link. So if there are a value in facebook metabox I got the logo and the link. Now my question, if One of this 4 metabox (facebook, twitter, instagram, youtube) has a value ( at least one of this 4 ), I need to show title "Follow Us on". Thank you


Is `is_sidebar_active()` deprecated, and showing error?

I **Googled** `is_sidebar_active()`, used by several WordPress trainer, but I came to the decision, the function's surely deprecated. But unfortunately I found no mention, even no entry in WordPress Codex. As a Wikipedian, I also edit the Codex sometime, but need the confirmation that, `is_sidebar_active()` IS DEPRECATED, and `is_active_sidebar()` is ON now. I used `is_active_sidebar()` instead of `is_sidebar_active()` in my theme and it's working fine. But I need a confirmation. Anybody?


why is markup routinely placed in functions in wordpress?

Here is an exampple from a woothemes theme. I'm definetly not having a go at woothemes - they are a great theme provider with great standards and this sort of thing is fairly typical in themes. why? Is this sort of code best practice in wordpress? I suppose I'm expecting view type stuff to be in a template file or partial, not in an php includes file               /*-----------------------------------------------------------------------------------*/     /* Optionally load top navigation. */     /*-----------------------------------------------------------------------------------*/          if ( ! function_exists( 'woo_top_nav' ) ) {     function woo_top_nav () {         if ( function_exists( 'has_nav_menu' ) && has_nav_menu( 'top-menu' ) ) {             global $woo_options;     ?>

                 <?php superstore_contact(); ?>                                      <?php wp_nav_menu( array( 'depth' => 6, 'sort_column' => 'menu_order', 'container' => 'ul', 'menu_id' => 'top-nav', 'menu_class' => 'nav fl', 'theme_location' => 'top-menu' ) ); ?>

           <?php         }     } // End woo_top_nav()     }


Snapshot Theme from WooThemes — empty 'alt' attribute

I´m using Snapshot theme from WooThemes. The code which resizes (width and height and size in kb), and shows the images (an 'a' tag, wrapping an 'img' tag) is this one:               <?php if ( get_option('woo_resize') ) { woo_get_image('image','210','280');?>       The problem is: I´ve setted the 'alt' text while posting and, when trying to see the post image source code, the 'alt' attribute, appears, empty. Does anyone has passed for this before? Any tips? The post which I wanted to have the 'alt' attribute is the first product in the first row, in the first column: http://kevingstongramado.p.ht/catalogo/?cat=28 I´ve tried to insert code manually, without the use of the theme´s functions.. Here´s what I´ve tried: EDIT (I´ve noticed posting one new post, that the code doesn´t resize in kb):               <?php $img_attr = wp_get_attachment_image_src($attachment->ID, 'image');     $image = wp_get_image_editor($img_attr[0] ); // Return an implementation that        //extends <tt>WP_Image_Editor</tt>     if ( ! is_wp_error( $image ) ) {     $image->resize(210, 280, true );     $image->save($img_attr[0]);     }     $alt = get_post_meta($attachment->ID, '_wp_attachment_image_alt', true);                 ?>     <a href="<?php echo get_permalink($post->ID); ?>" title="View <?php the_title(); ?>">         <img src="<?php echo get_post_meta($post->ID, "image", $single = true); ?>" alt="<?php      echo $alt;?>"/>      The code doesn´t resize in kb and, still don´t get the 'alt' attribute. I´ve tried using 'SEO Friendly Images' plugin. Doesn´t work for me. What should I do?


Lightbox gallery in a link

Here is what i try to get. Into WordPress a module plugin that allow me to make slideshow of image. create a portfolio name "castle" and another one name "bridge" and get 3-5 photo in each. Then, in a text, i will talk about a beautiful bridge name xyz and i like the name of the bridge to be a link, when i click this link, a modal window will appear with a slideshow (light-box evolution is perfectly what i like), then somewhere else, when i talk about the caste abc i like the name to be a link, when click, show a slideshow of thos 4 image uploaded. so the question, what plugin do that ? thanks for the help ! the way things work in the theme Barely Corporate from ThemeBlvd is AWESOME, but i think it's custom work for there theme ! I try to find a way to get the behavior i whant, i am not promoting any theme or telling this is better that that, i just have seen behavior a like to replicate for my site


How to add PHP code snippet to all Post pages?

I wrote a short PHP snippet that I want to include on all past and future posts. I can't figure out which PHP file to add it into that'll affect the change to all and only Posts. Can someone point me in the right way? Thanks.


What is the use of to_ping and pinged column?

Can anyone explain or show a reference for the use of `to_ping` and `pinged` column in the wp_posts table? It seems that my Googling skills have failed me. I wanted to do an experiment using the `pinged` column to save the `term_id` of a term that is related to this post record. I know that the proper way is to use custom field instead, but I wanted to reduce the mysql `inner join` in the WP_Query calls. Thank you in advance.


How To: Simple domPDF Example

Not quite sure if anyone here has used dompdf, but I'm in need of assistance. There's a plugin (post-pdf-export) that exports posts to PDF using dompdf. All I need to do is generate some html (`<html><body><p>PUT INVOICE HERE</p></body></html>`) and export that to a PDF object and attach it to an email. I have got all of the code "executing" but the PDF that is generated will not open in Adobe Reader, but the pdf generated by the post-pdf-export plugin will. Not sure where I'm going wrong, but here's the basics (and please, someone tell me what I'm missing): 1) Include the dompdf class (in functions.php):                   define('SSM_PLUGIN_PATH' , plugin_dir_path(  __FILE__  ) );         include(SSM_PLUGIN_PATH.'/dompdf/dompdf_config.inc.php' );      2) Add admin sub-menu item and call my function:                   add_submenu_page(              'ssm_main_menu', // Parent Slug             'Test PDF', // Page Title             'Test PDF', // Menu Title             'manage_options', // Capability             'test-pdf', // Menu Slug             'test_pdf_handler' // Function         );      3) Function exports html to pdf:               function test_pdf_handler()     {         $stuff = '<html>                     <body>                     <p>                         PLEASE WORK!!!                     </p>                 </body></html>';         set_time_limit(300);         ini_set('memory_limit', '-1');              $dompdf = new DOMPDF();         $dompdf->load_html($stuff);         $dompdf->set_paper( 'letter' , 'portrait' );         $dompdf->render();         $dompdf->stream('sample.pdf');              exit();     }      4) Result - PDF that will not open... HELP? **UPDATE:** To add to the confusion, the post-pdf-plugin dompdf directory loads perfectly, but when I go get the dompdf package directly from git and include it in my plugin, it fails to load. If someone doesn't know what's going on, can someone recommend another solution for generating PDFs in PHP in a WordPress plugin? **UPDATE 2:** After creating a blank plugin to test this (to see what I have wrong in my plugin), I did notice one difference. My plugin pushes content to the front-end using shortcodes so I used to get the error message `Warning: Cannot modify header information - headers already sent by (output started at H:\\...`. So, to get around this, I added the following to my plugin to clear that error, but I believe it is causing the creation of the PDF to fail:               add_action('init', 'do_output_buffer');          function do_output_buffer() {         ob_start();     }


attachment.php & flexslider—linking thumbnail to specific image

I am nearly there but need the help of the community to bring me home! I am linking from a "gallery overview" page (thumbnail grid) to a single, full-size image page (attachment.php) containing a slideshow. The user should then be able to use flexslider to scroll through the additional attached images. So far, this is all working correctly—in principle. The problem is that clicking on any thumbnail brings the user to the FIRST image in the gallery, rather than the actual image represented by the thumbnail. My attachment.php code is as follows:

     <?php                 global $post;                 $args = array(                     'post_type' => 'attachment',                     'numberposts' => -1,                     'post_status' => null,                     'post_parent' => $post->post_parent,                     'order_by' => 'menu_order',                     'order' => 'ASC'                 );                 $attachments = get_posts($args);                 if ($attachments) {                     foreach ($attachments as $attachment) {                         echo '
';                         echo wp_get_attachment_image($attachment->ID, 'large');                         echo '
';                     }                 }     ?>

      Any help would be greatly appreciated. Also, the test site can be found here (simply click on one of the thumbnails to see what I mean): http://www.adamprince.us/clients/mcnairevans/projects/confessions-for-a-son/ Many thanks!!!


Remove inline width and height definitions from post images (single.php)

I have exported around 300 posts out of Blogger and into WordPress. The posts are mostly made up of images as it’s a fashion blog. Everything went great import-wise but the problem is that all images have `width` and `height` attributes applied to them. I need to find a way to remove these attributes on all existing posts and all future posts. From there I will just apply the Bootstrap 3 class to make images responsive (`img-responsive`). What exactly should I be targeting here? The images are being spit out by `the_content()` and some people are saying it’s related to the `wp_get_attachment_image_src()` function but I’m not totally sure… the WordPress support forms are a total mess and all the blog posts I come across are outdated :-( Any help on this would be appreciated, thanks in advance!


Extending WP_Query — Optimise SQL query

I'm storing posts, a user follows in a custom table that has the columns `id`, `post_id` and `user_id`. To fetch posts that a user follows I have extended the WP_Query as follows:               class WP_Query_Posts_User_Follows extends WP_Query {         function __construct($args=array()) {             if ( !empty($args['followed_by']) ) {                 $this->followed_by = $args['followed_by'];                 add_filter('posts_where', array($this, 'posts_where'));             }             parent::query($args);         }              function posts_where($where) {             global $wpdb;             $table = $wpdb->prefix . 'post_followed_by';             $where .= $wpdb->prepare(" AND ID IN (SELECT post_id FROM $table WHERE user_id = %d)", $this->followed_by);             return $where;         }     }      If you notice there is sub-query in the `WHERE` clause. My understanding is that sub-queries are bad as they hinder performance and particularly in this case where the sub-query could potentially return hundred or thousands of `post_ids` that a user follows. What are the alternatives that I have, considering that I need to work with WP_Query and cannot run a custom SQL directly using `wpdb`?


Prev/Next Links Broken on Static Front Page Pagination

I've taken the example straight from the codex on this one, and my pagination is broken. Here's the codex page I copied/pasted the code from: https://codex.wordpress.org/Function_Reference/next_posts_link Everything is working. My posts are showing, and I get **only** the `next_posts_link`, however it only works until page `2`. The `previous_posts_link` never appears. I can only paginate to page 2, and I cannot go back or further. I'm using WordPress 3.5.2 and I have reset my permalinks after attempting this. I put a little debug section below to find how many max pages there are, the `var_dump` returns `float(87)`. And here's my PHP code. Any thoughts?               function homepage_test() {         // Set the limit of posts to show per page         $limit = 5;         // set the "paged" parameter (use 'page' if the query is on a static front page)         $paged = ( get_query_var( 'page' ) ) ? get_query_var( 'page' ) : 1;              // the query         $the_query = new WP_Query( 'showposts=' . $limit . '&paged=' . $paged . '&orderby=date&order=DESC' );              if ( $the_query->have_posts() ) :         // the loop         while ( $the_query->have_posts() ) : $the_query->the_post();                   the_title();         endwhile;              // usage with max_num_pages         next_posts_link( 'Older Entries', $the_query->max_num_pages );         //Debug to show how many max pages.         var_dump($the_query->max_num_pages);         previous_posts_link( 'Newer Entries' );              // clean up after our query         wp_reset_postdata();         else: ?>
<?php _e( 'Sorry, no posts matched your criteria.' ); ?>
         <?php endif;     }


wp_insert_post hook not being called with wp_publish_post or wp_insert_post?

I have a plugin that converts hashtags (any text that starts with #) into Wordpress tags. It's working great when I manually create a post via the Wordpress dashboard, but doesn't work when I programmatically create a post. Here's how I'm programmatically creating the posts: First I create a draft:               $post = array(       'post_content'   => $messagefordatabase,       'post_name'      => $publickey,       'post_title'     => $publickey,       'post_status'    => 'draft'     );          $post_id = wp_insert_post($post);      Then when it's time to publish the post, this code changes the draft's publish status. (This publishes the post, but doesn't run the plugin):               wp_publish_post($postid);      And lastly, here's the code from the plugin:               function hashtags_insert_post( $id, $data ) {       if (preg_match_all("/".HASHTAGS_REGEXP."/i", $data->post_content, $match)) {         $tags = implode(", ", $match[2]);              wp_add_post_tags( $data->post_parent, $tags );       }            return $id;     }     add_filter( 'wp_insert_post', 'hashtags_insert_post', 99, 2 );      So in summary, the first 2 chunks of code above don't run the plugin. How can I trigger the plugin from either of those 2 chunks of code? Thanks!!


trouble with featured image

I don't understand why this happens I created a new image size in functions.php called blog. Code looks like this                   add_theme_support( 'post-thumbnails' );     add_image_size('blog', 134, 134, false);       Yet for some reason when the featured image comes out as 134 by 58 when called like this                <?php the_post_thumbnail('blog'); ?>      Can anyone tell me why that is? The actual image uploaded to the library is much larger than that


Problems With Query and/or Template Part and/or PHP

I'm trying to show only the last article. I made content-latestnews.php and it worked before meddling with queries. Template part was shown, but after I tryed to show the actual content it would show page up to the query part. Category 1 (which is vesti ( _ser_.) = news) is there, there is like dozens of posts in that category. Nevertheless, it doesn't show anything even if query is left out. I'm using Wordpress 3.9. I've tried with:               <?php     $lastnews = new WP_Query('showposts=1&cat=1');     if ( $lastnews->have_posts() ) : while ( $lastnews->have_posts() ) : $lastnews->the_post();         // Include the latest news template.         get_template_part( 'content', 'latestnews' );     endwhile; endif;     wp_reset_postdata()     ?>      and               <?php         $lastnews = new WP_Query('showposts=1&cat=1');         while ( $lastnews->have_posts() ) : $lastnews->the_post();             // Include the latest news template.             get_template_part( 'content', 'latestnews' );         endwhile;     ?>      I even tried without query               <?php     if ( have_posts() ) :         while ( have_posts() ) : the_post();         // Include the latest news template.         get_template_part( 'content', 'latestnews' );         endwhile;     endif;     ?>      and               <?php          if ( have_posts() ) : the_post();         // Include the latest news template.         get_template_part( 'content', 'latestnews' );     endif;     ?>      Thank you for your time. This should be bare basic, but obviously I'm missing something simple.


Setting a homepage - doesn't seem to work

have a page (home) that runs a template page-home.php that I can access at mydomin.com/home. I am wanting to have this as my static homepage page, so accessible at mydomain.com/ however I cannot seem to get this to work. I have change the settings in permalinks to allow for a static homepage, and selected the page I would like to use from the dropdown select box. On saving and refreshing my site, I just get a blank a white screen. I assumed that as the suffix of the domain is no longer home that wordpress does not know to use the page-home.php I have changed the name of the file to be the following, home.php, index.php, homepage.php, page.php and all I get is white screen for my homepage, am I doing something wrong? in 5 years of using wordpress I have never had a problem setting a homepage. I have also disabled all plugins and set turn the on one by one to make there was nothing in them breaking the page, but no success. The page is very simple, it is just a loop display posts from a custom post type.


get_posts ignoring 'category' and displaying all posts

I'm going a bit crazy on this one. I'm trying to display a list of posts in a category on an Admin page in a plugin I am writing. The following code works fine on my dev server (OS X/Apache):               $args = array(         'posts_per_page' => $pageSize,         'offset'=> $offset,         'category' => 9     );          $posts = get_posts($args);          foreach ($posts as $key => $aPost) {         (...)     }      As you might suspect, I get only posts in the category with an ID of 9. Now, on my production server (Linux/Nginx) it shows all posts - as if the category argument was never set. I only mention the nginx/apache/linux/os x as everything else is running the same - same themes and plugins installed (with the exception of Jetpack on the production server). Any thoughts?


Tips for targeting widget dragable for WP Pointer on widgets.php page

I'm updating a widget plugin I wrote called Feature Me and am adding in WordPress pointers for first time users to help them find the widget after installing the plugin. However, I have come across a problem. The pointer has to have a target to go to which is either an ID `#` or a CLASS `.` (that's fine under normal circumstances). But on the widget page, all widgets are prepended with `widget-[somenumber]`. ![Screen of prepended widget number with the message I'd like to display](http://i.stack.imgur.com/ltY6N.png) If i know what [somenumber] is I can target it no problem, but 99% of the time, I won't know what the number is since it really depends on the order of the plugin's installation. On a different website, this is the ID of the widget: ![Screen of prepended widget number from a different website](http://i.stack.imgur.com/yXM5r.png) Hopefully you can see my problem. For context, I'm using this method of displaying the pointer from TutsPlus. Specific function for the above message here:               function fm_message_widget_location( $p ) {         $p['fm_message_widget_location'] = array(             'target' => '#widget-7_feature_me-__i__',             'options' => array(                 'content' => sprintf( '<h3> %s </h3> <p> %s </p>',                     __( 'Feature Me - Getting Started' ,'plugindomain'),                     __( 'Looking for Feature Me? It\'s right here! Drag the widget to create your first call to action!',                         'plugindomain')                 ),                 'position' => array( 'edge' => 'left', 'align' => 'middle' )             )         );         return $p;     }     add_filter( 'fm_admin_pointers-widgets', 'fm_message_widget_location' );      This would work fine if my widget was always in the 7th position, but it won't be. I've attempted to pass through regex for the target, but that doesn't work, I'm assuming because the javascript code treats it as a string. ie. `'target' => '#widget-[0-9*]_feature_me-__i__'` or `'target' => 'RegExp("#widget-[0-9*]_feature_me-__i__")'` So given all of this, has anyone ever been successful at targeting these individual widget "dragables" with success in their plugins? Any advice/recommendations would be most welcome.


Exclude sub category posts from category display

I have a post category structure like this:   * news   * news / conferences   * news / newsletter In Appearance > Menu, I have added 3 menu items. One each for the categories News, Conferences, Newsletter. However, the News page also displays posts from Conferences and Newsletter. How do I exclude posts from subcategories from being displayed in the parent category's page? Thanks


Sub Categories Keep Redirecting to Pages With Same Slugs

What I want to do is have a `news` category with two sub categories (`property-registration` and `property-revitalization`). Going to /news works fine. However going to _/news/property-registration_ or _/news/property- revitalization_ redirects to same-named pages instead (`/programs/property- registration` and `/programs/property-revitalization` instead). I have downloaded a couple of plugins that let me save templates to categories but none of them worked and still got the same results. My permalink structure is `/%category%/%postname%/` for reference and no category base is set.


Load plugin on specific page only

I have plugin I would like to use only on the contact page, however the script and css is being loaded on every page. Aside from the increased http requests, it is also causing another script to not work properly on another page. Is there a way to stop this plugin from loading anywhere else on the site? I know how to do this with normal scripts in the header, but I am not sure how to do this with a plugin that automatically injects scripts into the header. Thanks in advance.


Contact Form 7 plugin refreshing page on submit

For those with experience of the Contact Form 7 plugin - When I installed it, the form worked fine, and upon pressing the submit button, there was no page load, all done via Ajax, however now the page loads upon pressing submit. I have not made any changes to the form. I have tried deactivating then activating but the problem remains. Has anyone else had this problem before? Thanks


Using same directory for storing all uploaded images on a Wordpress network

I currently use a Wordpress network in order to run a number of sites, which all use the same template, plugins and images. As posts appear on a multiple sites, it makes sense to only upload images to one location (and have one copy of an image), rather than multiple ones. Could I perhaps achieve this by creating a custom rewrite? Or is there a better way to achieve this? **Background information** I am using WPThree Broadcast to 'broadcast' an image over multiple sites, and therefore also copy the images into their respective image libraries. I don't want the server to get cluttered with ten copies of the same image so instead am checking to see if the image is already in a site's `wp_posts` table, and then if not copying the `post` and `post_meta` data into that site's tables. However, I do _not_ wish to copy the actual image into a new upload folder, as the default WP is configured to do (e.g. into `/wp- content/blogs.dir/2/files/`), so instead I want all images to be uploaded to `/wp-content/uploads/`, the default upload folder for a standard WP installation.


Hide Overflow on a Specific WordPress Template

I'm trying to hide the overflow in CSS for specific template pages but can't seem to get it to work - I know that template pages are prefixed with a class but this doesn't seem to help targeting. I think I could use the is_page_template() function to hide the overflow with JS but this should be simpler with CSS. So this works...               html {         overflow: hidden;         }      but this doesn't work...               html .page-template-showreel-php {         overflow: hidden;         }      Any ideas why? Surely this should be possible with CSS.


Search multiple custom post types with tags

I have blog with some post and pages and a forum, i need a search such that it need to search tags in post and pages and not in forum (bbpress)               if ($query->is_search()) {         $postType = array();         $tagPostType = array();         $tags = array();         if (isset($_GET['taglist']) && is_array($_GET['taglist'])) {             $tagPostType = array('page','post');             $postType = array_merge($postType, $tagPostType);             $tags = $_GET['taglist'];          } else {              $postType =  array('forum','topic','reply','page','post');          }          if(isset($_GET['forums'])) {              $tags = '';              $postType = array_merge($tagPostType, array('forum','topic','reply'));          }          print_R($postType);          $query->set('tag_slug__in', $tags);          $query->set('post_type', $postType);         return $query;     }      i need to search tags in post/pages and not in forums.


Add frontend editor with media buttons for Visitors and display only their media

I'm trying to make a frontend blog post submit for registered users. I have this working without media, now trying to add media. The standard `wp_editor`               $content = '';     $editor_id = 'mycustomeditor';     $settings = array( 'media_buttons' => true);     wp_editor( $content, $editor_id );      doesn't seem to display the media button for Visitors. How can I show the Add media button for Visitors? Also, I would need to show each user only his uploaded media. How is that possible?


Restrict custom post type from appearing with ?post_types=

When appending the querystring post_types = "name of your post type", it displays all the posts. I am using a plugin that has its own custom post type which is restricted (only users that have purchased a membership can view it).. but today while messing around with searching, i discovered that post_types querystring. Is there a way to prevent this private custom type from showing up? are there other similar "magic" querystring in wordpress?


wp_nav_menu list children if on parent page but sibling if on sibling page

For example: About Page (Parent)   * History   * Mission & Vision   * Location If I'm on the About Page, I need the wp_nav_menu to show the three children pages. But if I'm on the History page, I need it to show History (with current class), Mission & Vision and Location. Is there a way to do this? Thank you.


Why WordPress architecture is not pure object oriented and it don't use MVC pattern?

I am pretty new in WordPress and PHP development (I came from Java and C#) and I am a bit   astonished about how WP is structured. Coming from Java and C# I'm used to work on totally object oriented architectures and now, working on WP, it seems to me that it is not totaly object oriented. For example the **function.php** file ino every theme is not a class but is a simple php file containing some functions, so it respect the old procedural model. At the same time it seems to me that WP don't use MVC pattern My question is: why WordPress (that is a modern CMS) don't use a totally Object Oriented paradigm and don't adopt the MVC model?


How to append unique numbers to new duplicated post titles/urls?

As of now if you create two (2) posts with the same title you get the following: `domain.com/test/ domain.com/test-2/` If you create a third post, you then get another url like: `domain.com/test-3/` I am working on a directory, so the odds of someone having the same name is pretty good; therefore I want to append a custom url string to the end of the duplicated name - not just a 1 digit number. Is there a way for me to add a custom 4-5 digit string at the end of a duplicate post/page/listing? So that it reads: `domain.com/test/ domain.com/test-#####/ < the random string` thanks!


Adding category ID or slug to WP Nav Menu

Is it possible to add the id or slug of a category in the output of wp_nav_menu menu's? For example, the standard output of wp_nav_menu is:

Home

Category 1

Category 2

Category 3

      I'm wondering if it is possible to add the category slug to the css class for that `<li>`, like so:

Home

Category 1

Category 2

Category 3


WooCommerce plugins permalinks？

I use WooCommerce.   My links are looking like this at the moment:               http://www.mywebsite.com/shop/sample-product/      but I want them to be like this:               http://www.mywebsite.com/shop/1.html/     http://www.mywebsite.com/shop/2.html/     http://www.mywebsite.com/shop/3.html/     http://www.mywebsite.com/shop/4.html/     http://www.mywebsite.com/shop/5.html/     http://www.mywebsite.com/shop/x.html/      how do I change them?


Multiple image not being Uploading inside fieldset in Custom Field Template Plugin version 2.1.5 wordpress

In Custom Field Template Plugin 2.1.5 Multiple image in not being uploaded/saved after clicking Update button. Can anyone kindly help me with this ? Optimistic to find the fix. http://wordpress.org/extend/plugins/custom-field-template/


Prioritizing wp enqueue scripts error

I wanted to load the following two scripts before any other script so I added priority 1 and 2, however I am getting an error. I read it on a tutorial that this is how to prioritize                add_action('wp_enqueue_scripts', array(__CLASS__, 'frontend_enqueues', 1));             add_action('print_head_scripts', array(__CLASS__, 'print_js', 2));      > Warning: call_user_func_array() expects parameter 1 to be a valid callback, > array must have exactly two members in xxx/xx/xxx/wp-includes/plugin.php on > line 406 > > Warning: call_user_func_array() expects parameter 1 to be a valid callback, > array must have exactly two members in xxx/xx/xxx/wp-includes/plugin.php on > line 173 Please advice :)


Question regarding WP multisite feature

Hi I am developing a networking website using wp multisite feature. The website will have three different sites.   1. buystuff.abc.com   2. sellstuff.abc.com   3. rentstuff.abc.com Now if "X" person register on buystuff.abc.com and complete his profile. Will he be able to access the other two sites with same credentials used on to register on buystuff.abc.com?


More than one dynamic sidebar

I created 3 dynamic sidebars in my function.php file, everything went well, no problems. in a file named, sidebar-services.php, I have the following code.               <?php     /**      * The Sidebar containing services      *      * @package Group Joosen      */     ?>                  <?php if ( ! dynamic_sidebar( 'service1')): ?>                            <?php endif; // end sidebar widget area ?>               <?php if ( ! dynamic_sidebar( 'service2')): ?>                            <?php endif; // end sidebar widget area ?>                  <?php if ( ! dynamic_sidebar( 'service3')): ?>                            <?php endif; // end sidebar widget area ?>      In my front-page.php I have:

          <?php get_sidebar('services');?>

      **Everything is working fine** , I only have the feeling this is not the right way. Is there any possibility that I can have all the **div classes** in the sidebar-services.php file? In that file I want to "ask" for my 3 sidebars with one if-statement, otherwise it will create the classes 3 times. Hope you understand guys ------EDIT-------- * _Why is this not working? This is what I mean with "more compact code" *_               <?php if ( ! dynamic_sidebar( 'service1' ) and (! dynamic_sidebar( 'service2' ))): ?>                                <?php endif; // end sidebar widget area ?>


Font type by language: Latin - Greek - Cyrillic

How I get type of font (Latin, Greek, Cyrillic), which is required in wordpress site? It may be based on language. I need this for including Google font - I don't want to include all font sets. I need to get GET parameter `subset`               <link href='http://fonts.googleapis.com/css?family=Open+Sans&subset=latin,greek'      rel='stylesheet' type='text/css'>      Solution should work on multisites and with any multi-language plugin.


How to use custom fields to enable sticky posts on custom post types?

**Background:** The Wordpress Answers site has two questions which ask about how to enable sticky posts on custom post types (see how to make custom posts sticky? and Enable sticky posts to custom post_type ). Both questions made mention of this trac ticket ( https://core.trac.wordpress.org/ticket/12702 ). The answers provided ( _to those questions I mentioned above_ ) express a possibility of using custom post types and meta-boxes. Unfortunately the level of detail in those answers was not helpful to me (and, I presently don't have enough reputation to comment for further clarification). **My Goal:** I am using the custom post type ui plugin and the advanced custom fields plugin to display employee profile CPT's. One one of my pages lists all of the employee profiles, but the client wants certain profiles to be stick to the top. I have reviewed two possible plugins to assist me (seamless sticky custom post types and sticky custom post types). Unfortunately, those plugins seem only to output the sticky post on the homepage. For my purposes, the sticky-feature should only apply to the specialized page template that lists all the employee profiles, and not the home page. **Question Restatement:** It seems like the best solution for me involves somehow using custom fields to accomplish the desired result. Is this correct? If so, please direct me to any wordpress template tags, techniques, examples or tutorials that might help.


About number of posts in selected category

I have lots of categories. And each category contains many images in posts. I want to display '(current number of post)/(total number of posts in selected category)' for example: 3/9   where 3 = current number of post 9 = total number of posts in selected category There are so many categories and I do not want to write code for each category. Is there any way to solve it?


Configure Permissions in Mamp

I recently built a website on Mamp, and upon uploading to my hosting server, I seem to have lost permissions. My guess is that the migration from local to server brought the permissions with it. You can see here `http://162.213.156.137/~healthy/`, in the left lower area of footer that the images are not loading in. I also had the two images in the header (little girl and logo) not load in either until I used FTP to manually change permissions. I'm wondering if anyone has dealt this before and has advice or if you know how to configure MAMP to have proper settings from the get go.


How to create separate shop pages in woocommerce for each product category i.e. computers, cameras, cellphones, software, books, etc.


How to call custom function outside from the admin page?

I've created a function but i have some problems with it...                echo get_option( 'my_function', 'custom_logo' );      I try to use this in my code but it returns me an array not a string. When i use `echo $options['custom_logo'];` on my plugin backend admin page the code returns the value as a string. So how can i call it from my theme for example?


Show all 12 months regardless they have posts

I need to show all months for a year for an archives page. All 12 months must be shown regardless of whether or not there are posts published for a month. Like this: Year: Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec Of course, months with published posts are links. Months with no published posts are simply the word This is my code:
          <?php         global $wpdb;         $limit = 0;         $year_prev = null;         $months = $wpdb->get_results("SELECT DISTINCT MONTH( post_date ) AS month , YEAR( post_date ) AS year, COUNT( id ) as post_count FROM $wpdb->posts WHERE post_status = 'publish' and post_date <= now( ) and post_type = 'post' GROUP BY month , year ORDER BY post_date DESC");         foreach($months as $month) : $year_current = $month->year;         if ($year_current != $year_prev){ if ($year_prev != null){ ?>              <?php } ?>
 <a class="year" href="<?php bloginfo('url') ?>/<?php echo $month->year; ?>/">> <?php echo $month->year; ?>              <?php } ?>              <a class="month" href="<?php bloginfo('url') ?>/<?php echo $month->year; ?>/<?php echo date("m", mktime(0, 0, 0, $month->month, 1, $month->year)) ?>"><?php echo date_i18n("M", mktime(0, 0, 0, $month->month, 1, $month->year)) ?>              <?php $year_prev = $year_current; if(++$limit >= 10) { break; } endforeach; ?>

      I achieved what I pretend to do except for showing all the 12 months.


Custom theme folder

Is anyone aware of an equivalent to `WP_PLUGIN_DIR` and `WP_PLUGIN_URL` for themes that I can define in `wp-config.php`, or am I stuck creating a mu- plugin and registering a new theme dir?


Prevent Page/Post From Being Created based on Pages/Posts per User per Time Unit

I'm working on new project and I want to let users have access to create pages on the site. To prevent users from "spamming" a lot of pages, I'd like to set a daily upload limit for each user. I've posted the code I'm using below but I'm not able to cancel the page upload because the event is being fired after a page has been created and added to the database. Worst case scenario, I can search the database and delete the document they just created but I don't think that that's the best solution. Is there a hook similar to pre_post_update that I can use to check and or cancel the page from being uploaded? If there isn't a hook I can use, is there a better way to solve this problem?               add_action( 'save_post', 'check_post_limit' );          function check_post_limit( $post_id ) {     global $userdata;     global $post_type;     global $wpdb;     if( $userdata->ID != 1) {         $post_count = $wpdb->get_var( "SELECT count(*) FROM $wpdb->posts WHERE DATE(post_modified) = DATE(NOW()) AND post_author = $userdata->ID" );     }     if( $post_count > 3 ) {         wp_die(); //will not work because page is already in the database     }     }


Woocommerce Multiple Tags Archive URL

I'm curious if there's any easy way to setup WooCommerce to show an archive page of multiple different tags. For example a URL like http://www.domain.com/products/?tag="toys"&tag="electronics" would show an archive page for both toys and electronics. What I'm really trying to do is have a (Gravity Forms) form that sends users to specific groups of products by tag based on their answer to a short questionnaire.


Pre_Get_Posts order DESC not registering

I've created a filter function to filter a post type `items` by it's meta value `_item_price`. The problem is that it only works in Ascending Order and I'm not sure why. My `pre_get_posts` function looks like this:               function frontend_items_filter( $query ) {         global $page_items_id              if(!is_page($page_items_id))             return;              if($query->query_vars['post_type'] == 'items' && isset($_GET['filter'])){             $sort = $_GET['item_sort'];                  // Set Ordering Parameter             if(isset($_GET['item_sort']) && !empty($_GET['item_sort'])){                 switch($_GET['item_sort']){                          case 'price_lowest':                         $query->set('meta_key', '_item_price');                         $query->set('orderby', 'meta_value_num title');                         $query->set('order', 'ASC');                             break;                          case 'price_highest':                         $query->set('meta_key', '_item_price');                         $query->set('orderby', 'meta_value_num title');                         $query->set('order', 'DESC');                              break;                          default:                         $query->set('orderby', 'post_date title');                         $query->set('order', 'ASC');                 }             }         }         return $query;     }     add_action( 'pre_get_posts', 'frontend_items_filter' );      Before I save my price meta I'm verifying it's `is_numeric()`. I tried to print out my query and run the SQL directly into PHPmyadmin, If I take the SQL below and change ASC to DESC, in my PHPmyadmin the results don't change which is peculiar.               SELECT SQL_CALC_FOUND_ROWS  wp_posts.ID FROM wp_posts         INNER JOIN wp_term_relationships              ON (wp_posts.ID = wp_term_relationships.object_id)          INNER JOIN wp_postmeta              ON (wp_posts.ID = wp_postmeta.post_id)          WHERE 1=1           AND ( wp_term_relationships.term_taxonomy_id IN (10) )          AND wp_posts.post_type = 'items'          AND (wp_posts.post_status = 'publish'          OR wp_posts.post_status = 'private')          AND (wp_postmeta.meta_key = '_item_price' )          GROUP BY wp_posts.ID          ORDER BY wp_postmeta.meta_value+0,wp_posts.post_title ASC LIMIT 0, 10      Every time it pulls my results back in `_item_price` Ascending order (lowest price to highest price). What could the problem possibly be? What else can I check / verify? **Edit** I've tried this with a few other fields I have and it's the same result - it will show ASC but not DESC.