How to create a page with links to other pages that include image and excerpt?

I have several pages (not posts) on my Wordpress site. They contain excerpts (I forgot which plugin enabled that) and have an article image. Now I would like to create another page that contains selected links to those pages. I would like to just select the pages and have those links created automatically with the excerpt text and the picture. I found a plugin which does that, and it looks ok. It's just that the plugin is quite old and has not been updated for two years or so. I searched a really long time now and have not yet found any. Is there another way to achieve this?


Redirect blog archive into certain format

My blog archive URLs were like:               http://example.com/2014/03      I changed my site's permalink from `/%postname%/` to `/%postid%/%postname%/`, and using Redirection plugin, I set a redirection like: ![redirection 1](http://i.stack.imgur.com/mOLdu.png) and it's working. But the problem occurs in the archive URLs. The new archive URL generated with a /date/ basename before the dates, like:               http://example.com/date/2014/03      I'm trying to use the same Redirection plugin to redirect the URL, but failed: ![redirection 2](http://i.stack.imgur.com/FTtUs.png) I then tried writing `.htaccess` on my own (with no `.htaccess` writing experience) with:               Redirect permanent http://example.com/([0-9]+)/([0-9]+) http://example.com/date/([0-9]+)/([0-9]+)      with the help of htaccess editor and this blog. But failed too. How can I let my blog not to get 404 on such archive URL? I'm afraid, I'm dumb with rewrite rule till now. :(


Checking that the Rewrite API is available

WordPress supports URL rewriting through the Rewrite API. It relies on underlying HTTP server mechanisms to get the job done. It is not always possible for WordPress to enforce the Rewrite rules. For example, with Apache, when WordPress isn't allowed to create the .htaccess file. The plugin I'm writing should take advantage of the Rewrite API, when it is available. Basically:               if (is_url_rewriting_available( ) ) {         Plan A     } else {         Plan B     }      But I can't find such function. What I investigated so far:   * Nothing in the doc, in particular in https://codex.wordpress.org/Class_Reference/WP_Rewrite   * "Write" functions, such as `flush_rewrite_rules`, return nothing. So it can't be used to check the availability (eg. `if (false == flush_rewrite_rules () )`).   * In `wp-admin/options-permalink.php`, around line 130, the code checks URL rewriting requirements. However, this code doesn't seem to be reusable. Sure, I can copy/paste this code but...


Giving auto update functionality to my theme

I have created a free wordpress theme. I want to give the users the ability to auto update the theme from the dashboard if there exists a update in mysite. We can see that when we are using wordpress.org themes right? Please tell me what is the solution for that?


How to move theme directory but not plugins/uploads out of WordPress root directory?

I am trying to set up a few local multisite installs that will share the same themes folder, but have separate upload and plugin folders that will be in the usual places in `wp-content`. UPDATED: WordPress is installed at `/Users/josh/Documents/Websites/themedev.dev/` and I've create the new theme directory at `Users/josh/Documents/jp-content/jp- themes` and put twenty twelve into it for testing purposes. Per Otto's suggestion below I created and activated a plugin that is just this:               $directory = '/Users/josh/Documents/Websites/jp-content/jp-themes';     register_theme_directory( $directory );      That showed twenty twelve in the theme admin page, but on the front-end I got a blank page, and the page source was totally empty. When I changed the first line to `$directory = '/Users/josh/Documents/Websites/jp-content/jp-themes/' (note the trailing slash,) I got the theme, but not the style. When I echoed the value of`get_template_directory_uri()`I got`Users/josh/Documents/Websites/jp- content/jp-themes//twentytwelve`which would explain it. I tried using`trailingslashit` instead of adding the slash like this:               $string = '/Users/josh/Documents/Websites/jp-content/jp-themes';     $directory = trailingslashit( $string );     register_theme_directory( $directory );      and got the same results. I still can't figure out what I'm doing wrong here...


Query for draft or scheduled post

What should be the query for checking if there is any draft or scheduled post, I'm not able to make which arguments to take. Thanks


Automatically add image caption with values from a post parent field?

i have a custom dropdown field on post and i would to get the value from that custom field and insert it on each image caption field uploaded to the current post. I have been looking for a way to do this and found a couple of examples but not even one work. This morning i found a Wordpress filter that is called attachment_fields_to_save. To my surprise on the codex was an example of almost the same thing i was looking for but i didn't work. This is the code               function insert_custom_default_caption($post, $attachment) {     if ( substr($post['post_mime_type'], 0, 5) == 'image' ) {         if ( strlen(trim($post['post_title'])) == 0 ) {             $post['post_title'] = preg_replace('/\.\w+$/', '', basename($post['guid']));             $post['errors']['post_title']['errors'][] = __('Empty Title filled from filename.');         }              // captions are saved as the post_excerpt, so we check for it before overwriting         // if no captions were provided by the user, we fill it with our default         if ( strlen(trim($post['post_excerpt'])) == 0 ) {             $post['post_excerpt'] = 'default caption';         }     }          return $post . $attachment;     }          add_filter('attachment_fields_to_save', 'insert_custom_default_caption', 10, 2);      Can anyone help me to see what is wrong with that code?


Enable Woocommerce chart, price and buying functions if only user is specific role, otherwise use as catalog

I would like to make a e-commerce site that use as catalog for visitors or users that less than specific role capabilities.   Eg: if i enable the woocommerce for Editors than editors and above will be capable to see prices, add to chart and check-out (chart visibility and functionality), all other members and visitors will only can see the products as catalog.   I've tried many things but most of them just for logged/visitor seperation.   Thanks right now.


Automatically add widgets to all pages

I have created a few pages and made them into menus. Also i'm using widgets on pages. Some of the widgets should be in all pages. In every page i need to add a short-code to that widget. Is there any way to automatically add widgets to all pages? Maybe i should i alter the edit.php source code?


wp_enqueue and Dependencies

Easy Question: If I enqueue a script as follows: Version A:               wp_enqueue_script('my-script', plugins_url( '/path/to/file', __FILE__ ), array('jquery', 'jquery-ui-core'));      Do I need to enqueue jquery and jquery-ui-core? As below: Version B:               wp_enqueue_script( 'jquery' );     wp_enqueue_script( 'jquery-ui-core' );     wp_enqueue_script('my-script', plugins_url( '/path/to/file', __FILE__ ), array('jquery', 'jquery-ui-core'));      Or does listing the scripts that it's dependent on (as in Version A) automatically handle that?


Attempt to improve WP search, can someone check my SQL query?

I'm stumped. I've done a bunch of work to filter what posts get pulled in a WP search and then even more work sorting those after they're pulled from the DB. My main problem now is getting results matched by Tag. I've just been running the straight SQL query and checking the output rather than running it through WP over and over. First the search query as WP generates it (my filters added and I've expanded out the important part):               SELECT SQL_CALC_FOUND_ROWS       wp_3_posts.ID FROM wp_3_posts       LEFT JOIN wp_3_term_relationships AS trel ON (wp_3_posts.ID = trel.object_id)     LEFT JOIN wp_3_term_taxonomy AS ttax ON (  ( ttax.taxonomy = 'post_tag' )       AND trel.term_taxonomy_id = ttax.term_taxonomy_id)      LEFT JOIN wp_3_terms AS tter ON (ttax.term_id = tter.term_id)       WHERE 1=1       AND      (      (       (        (         (wp_3_posts.post_title LIKE '%neck%')          OR         (wp_3_posts.post_content LIKE '%neck%')        )         AND         (         (wp_3_posts.post_title LIKE '%pain%')          OR         (wp_3_posts.post_content LIKE '%pain%')        )       )        OR        (        (         (tter.name LIKE '%neck%')         AND         (tter.name LIKE '%pain%')        )        OR         (tter.name LIKE '%neck pain%')       )         OR        (        (         (wp_3_posts.post_excerpt LIKE '%neck%')          AND         (wp_3_posts.post_excerpt LIKE '%pain%')        )         OR        (wp_3_posts.post_excerpt LIKE '%neck pain%')       )       )     )       AND (wp_3_posts.post_password = '')       AND wp_3_posts.post_type IN ('post', 'page', 'attachment', 'syndicated')      AND (wp_3_posts.post_status = 'publish')       ORDER BY wp_3_posts.post_date DESC LIMIT 0, 7      The first part which grabs the necessary tables with joins seems to be just fine. The search I'm running is for "neck pain" and any posts with those words in the title, content, or excerpt show up as expected. I have one post tagged "neck", "pain", and "neck pain". That post ID does not return with this query. What driving me nuts is that if I remove the part of this query that looks into the post_content and post_title, my tagged post _does_ show up. Specifically, if I remove this:               (((wp_3_posts.post_title LIKE '%neck%')      OR (wp_3_posts.post_content LIKE '%neck%'))      AND ((wp_3_posts.post_title LIKE '%pain%')      OR (wp_3_posts.post_content LIKE '%pain%')))      OR       which leaves my query as               SELECT SQL_CALC_FOUND_ROWS       wp_3_posts.ID FROM wp_3_posts       LEFT JOIN wp_3_term_relationships AS trel ON (wp_3_posts.ID = trel.object_id)     LEFT JOIN wp_3_term_taxonomy AS ttax ON (  ( ttax.taxonomy = 'post_tag' )       AND trel.term_taxonomy_id = ttax.term_taxonomy_id)      LEFT JOIN wp_3_terms AS tter ON (ttax.term_id = tter.term_id)       WHERE 1=1       AND      (      (        (        (         (tter.name LIKE '%neck%')         AND         (tter.name LIKE '%pain%')        )        OR         (tter.name LIKE '%neck pain%')       )         OR        (        (         (wp_3_posts.post_excerpt LIKE '%neck%')          AND         (wp_3_posts.post_excerpt LIKE '%pain%')        )         OR        (wp_3_posts.post_excerpt LIKE '%neck pain%')       )       )     )       AND (wp_3_posts.post_password = '')       AND wp_3_posts.post_type IN ('post', 'page', 'attachment', 'syndicated')      AND (wp_3_posts.post_status = 'publish')       ORDER BY wp_3_posts.post_date DESC LIMIT 0, 7      Maybe there's something I'm not understanding about SQL here, I'm a bit of a hack at it. Any wisdom would be much appreciated, thanks!


do_shortcode within post query

I am querying blog posts with a specific category (according to the template page slug, and want each post to output a slider, title and content. I'm using the wordpress plugin Anythingslider for Wordpress. I am creating slides with the same category as the post slugs so that everything is automated and less copy and paste - however when I add the do_shortcode line, it duplicates the same post (for as many times as there are posts), instead of displaying EACH post! Anyone have any ideas?                   <?php        $args = array(         'post_type' => 'post',         'category_name' => $post->post_name,         'showposts' => 20,      );          $the_query = new WP_Query( $args );           $page_id = get_the_ID();     $page_object = get_page( $page_id ); ?>

<?php echo $page_object->post_content; ?>

Title

             <?php if ( $the_query->have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); ?>              <a href="#<?php echo $post->post_name; ?>"><?php the_title(); ?>                  <?php endwhile; wp_reset_postdata(); ?>             <?php endif; ?>

                        <?php if ( $the_query->have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); ?>     <div id="<?php echo $post->post_name; ?>">

             <?php $shortcode = do_shortcode('[anything_slides cat='.$post->post_name.']');                 echo apply_filters('my_new_filter',$shortcode); ?>

<?php the_title(); ?>
             <?php echo the_content(); ?>

          <?php endwhile; wp_reset_postdata(); ?>     <?php endif; ?>


get_posts() in secondary sidebar messes up content in primary sidebar

I use get_posts() to generate a menu of posts having the current page as the parent. This causes the post_id to be set to the first such post, instead of the original page's post_id. I.e. I want Wordpress to continue as if nothing happened after the query. This is the code I use in sidebar.php:               $args = array(     'posts_per_page'   => -1,     'offset'           => 0,     'category'         => '',     'orderby'          => 'title',     'order'            => 'ASC',     'include'          => '',     'exclude'          => '',     'meta_key'         => '',     'meta_value'       => '',     'post_type'        => $slug,     'post_mime_type'   => '',     'post_parent'      => '',     'post_status'      => 'publish',     'suppress_filters' => true );          $pt=get_the_title();     $posts=get_posts($args);     //loop children custom posts.     if ($posts) {         echo '
';         echo '

'.$m.'';         // Start the Loop.         foreach ($posts as $p) {                  $t=get_the_title($p->ID);             $l=get_permalink($p->ID);             $a='';if ($t==$pt) $a=' class="active"';             echo '

';             echo ''.$t.'';             echo '

';              }   //foreach         echo '

';     }   //if has posts      All available information says get_posts() doesn't affect anything. Well, that's confirmed to be a lie, unless you can spot an error in my code. If I comment out the single line `$posts=get_posts($args);`, main content is OK. I have tried using wp_reset_postdata(), no difference. Thankful for any help by the pros here :)


Echo order box (in pages)

How can I echo the value of the order box in posts? See photo.![enter image description here](http://i.stack.imgur.com/VdldU.png)


Add the ".current-menu-item" class to <a> tag?

I am changing `wp_nav_menu()` to make it a listless navigation menu (i.e., no unordered list or list item tags) Normally the menu `<li>` has the `.current- menu-item` class attached to it when active. But is there a way to give it to the anchor instead? `<a class="current-menu-item"></a>` Edit: This is currently what I'm doing to remove the tags... if there's a custom walker solution that would be ideal. I'd prefer not having to resort to using any javascript if possible.               $menuParameters = array(       'container'       => false,       'echo'            => false,       'items_wrap'      => '%3$s',       'depth'           => 0,     );          echo strip_tags(wp_nav_menu( $menuParameters ), '<a>' );


WooCommerce shop page overwriting my shop intro text above the listings

I recently switched to WooCommerce from Jigoshop and upon doing that my shop page now doesn't display the intro text that I had above all my items on the shop page. If I go to my "shop page" in the dashboard it displays my intro text but when I go to the live view after publishing it, it's gone. Why would this be happening? My items for sale are being pulled into the shop page but my custom intro text isn't showing up on the live site anymore even though it's there in the dashboard. I wanted to give an overview on my shopping page with some intro text above the actual shop items. How can I fix this?


How do I dynamically populate wp_nav_menu from a custom taxonomy?

I know this question has been asked in different forms. But as far as I can tell from searching Google and SE/WP it's never been satisfactorily answered. Let's say I have a taxonomy _clubs_ and a custom post type _person_. On each `taxonomy-club.php` page I display all the _people_ who are members of that _club_. **But** I want to achieve a similar effect in my menus:               wp_nav_menu     |     |--Everyone     |  \     |  |- Mr Verlaine     |  |- Mr Lloyd     |  |- Mr Osterberg      |  |- Mr Williamson         |     |--Snooker Club     |  \      |  |- Mr Osterberg      |  |- Mr Williamson     |     |--Golf Club     |  \     |  |- Mr Verlaine     |  |- Mr Lloyd      If possible, I would like my menus to have the current page highlighting functionality of `wp_nav_menu()`. I've experimented with this:               add_filter('wp_nav_menu_items','add_terms');          function add_terms($items) {     $items .= '<li>' . wp_list_categories( array(         'taxonomy' => 'clubs',          'title_li' => 'Clubs') )           . '</li>';     return $items;     }      but it doesn't populate the submenus with the people's names, and it doesn't have that nav_menu css-class goodness. Must I create a more complicated `<li>` by querying out the posts in each term of the taxonomy, paste that in, and that's my lot? Or extend the built-in walker (will it give me the advantages of wp_nav_menu?) Or something else... Thanks!


Are href attributes of a elements filtered on output to add the current path?

I have some code that basically looks like this (it's more complicated, but even this example shows what I'm running into):               echo 'TEST';      However, what gets sent to the browser is not `<a href="#">TEST</a>`, but instead `<a href="http://example.com/current-page#">TEST</a>`. Is WordPress filtering this somehow to prepend the current page URL in front of the `#`? It just occurred to me that this code is being called by a shortcode, which I imagine opens up the possibility of it being filtered somehow...


Limit the number of child page displaying

I created a code for querying child pages when we're on a parent page and also display brother pages if we are on a child page, and works amazing... now my problem is, I cannot find a parameter like post_per_page that allow me to limit the number of page displaying, so far I need to display 5, but if a 6 is added the style breaks... so at the end of the day I just want to limit the number of view to X number, lets say 5. Take a look at the code
          <?php           $children = wp_list_pages('title_li=&child_of='.$post->ID.'&echo=0');           $subpages = ($post->post_parent) ? wp_list_pages('title_li=&child_of='.$post->post_parent.'&echo=0') : wp_list_pages('title_li=&child_of='.$post->ID.'&echo=0') ;                if ($children) { ?>
<?php echo $children; ?>
               <?php } else { ?>                  <?php echo $subpages; ?>          <?php } ?>
            Thanks in advance. UPDATE* _*_ I found this solution after a while                <?php $this_page_id=$wp_query->post->ID; ?>        <?php query_posts(array('orderby' => 'menu_order', 'order' => 'ASC', 'posts_per_page' => 2, 'post_parent' => $this_page_id, 'post_type' => 'page')); while (have_posts()) { the_post(); ?>
<?php the_title(); ?>
             <?php } ?>        <?php wp_reset_query() ?>      I'm able to use the post_per_page function and works like charm!


Using custom meta_query with relation not working as expected

I am trying to create a query to pull future events only. It was working great until the client requested the ability to add date ranges--so the event will either have a start date only, OR a start date and an end date. I need to build a query that pulls events events that has a start date in the future OR an end date in the future. This does not work as expected and pulls all events; and the order of what's pulled seems random, despite setting orderby to meta_value. Any help would be much appreciated!                   function get_upcoming_events($num) {         $today =  gmdate('Y-m-d', time()-28800);              $args = array(             'meta_key'          => 'event_date',             'order'             => 'ASC',             'orderby'           => 'meta_value',             'post_status'       => 'publish',             'posts_per_page'    => $num,             'post_type'         => 'events',             'meta_query' => array(                 'relation'=>'OR',                 array(                     'key' => 'event_date',                     'type' => 'DATE',                     'value' => $today,                     'compare' => '>='                  ),                 array(                     'key' => 'end_date',                     'type' => 'DATE',                     'value' => $today,                     'compare' => '>='                  )             )         );              if ( isset( $data[ 'taxonomy' ]) ) {             $args[ 'tax_query' ] = array();             $args[ 'tax_query' ][0] = array(                 'field'     => 'slug',                 'taxonomy'  => 'event-type',                 'terms'     => 'general'             );         }         $myquery = new WP_Query( $args );         return $myquery;         }


How to add tags to identify custom post types in archives?

The most important thing I would like to add that is missing from my site is colored post type tags for each of my 7 custom post types within the category archives, search archives, and tag archives (which all use the same template file). I was able to manually add colored post type tags to each of the 7 single.php files by adding the following code (this one is for single- articles.php):
Articles
;      I think that what I need for the archive template is for the 7 codes for each post type to be there within the loop, but it needs to be conditional or something depending on which post type is being called. I just don't know what the PHP code is that I need to use to do this. Here is what I have added to the archive template in order to get the custom taxonomies for each custom post type to work:
<?php the_terms( get_the_ID(), 'articles-archives', ' ', '
' ); ?>

<?php the_terms( get_the_ID(), 'questions-archives', ' ', '
' ); ?>

<?php the_terms( get_the_ID(), 'videos-archives', ' ', '
' ); ?>

<?php the_terms( get_the_ID(), 'documentaries-archives', ' ', '
' ); ?>

<?php the_terms( get_the_ID(), 'ted-talks-archives', ' ', '
' ); ?>

<?php the_terms( get_the_ID(), 'memes-archives', ' ', '
' ); ?>

<?php the_terms( get_the_ID(), 'music-archives', ' ', '
' ); ?>
      And here is the code for the tags that appears just after it:
<?php the_tags('
', ' ', '
'); ?>
      So I'm assuming I would need to add similar PHP code as what is used for the taxonomy terms, but I just don't know what it is... Does anyone know?


Displaying a variable stored in functions.php inside widget

I'm trying to display a variable that is stored inside my functions.php file - for the sake of the question this variable is stored as `$test = 'test';`. When i use `echo $test` inside page.php, header.php or any other file the value is returned however when i try to do the same inside a widget (i'm using a plugin that allows execution of PHP inside a widget) nothing happens. Any ideas as to how i could get around this?


Extend Media Library

The Media Library in WordPress has "Insert from URL" link to the left. It accepts image URLs. It's not said anywhere but if you paste YouTube URL or `<iframe>` code then it will insert it too. It just won't show the preview like it does with image URLs so you can't tell if the code you typed in is valid or not.   1. I'd like to edit this page and make it show previews of valid WordPress Embeds and of valid `<iframes>`. I want it to just show basic information that the embed code was recognized, is valid and can be inserted. I can write all the AJAX requests to validate URLs but I need help with `wp.media` object. I have no idea how to update that page or replace it with my own page? So far I've found /wp-includes/js/media-editor.js where on line 1054 it says `Called when 'Insert From URL' source is not an image. Example: YouTube url.`.   2. Secondly, once it's already done, I'd like to be able to call something like the following piece of code to open the Media Library with "Insert from URL" page selected and with the code added (for users to modify the existing code). The code (this is a working example of how to bring a window for editing images but I need this for "Insert from URL"):               frame = wp.media({         frame: 'image',         state: 'image-details',         metadata: { 'url': 'some-url' }     });     frame.open();


Displaying Gravity Form data on Wordpress page

How can I display the data from within a Gravity Form on a Wordpress page? (This may be too detailed, but in case anybody wants details about what I'm trying to do, here they are): I have two Gravity Forms - a pledge form, and a recruit form:   * The recruit form (e.g. www.test.com/recruit) is used to create a referral URL that adds a user-specified code onto the end of the pledge form URL. It also captures the user's email.   * The pledge form (e.g. www.test.com/pledge) is used to capture user information (name, email, etc.), and when a user fills it out with a URL that contains a referral code (e.g. www.test.com/pledge/?referrer=iamthereferralcode), the form also captures that code in a field called "referrer".  I need to display the top 5 referral URLs and their email addresses on a certain page on my Wordpress site. I'd appreciate any insight. Thank you!


Editing Admin via Child Theme

The theme I'm using provides an admin page that lets me easily setup jQuery sliders on my homepage, but it limits me to five. Now I'm able to go into the actual theme files and edit these so that the backend asks for 7 slides and the front end displays all 7. No problems there, I know exactly where and what to edit. But... editing the theme is not advisable and child themes are the way to go. However, I can't figure out how to make these changes in the child theme, specifically the backend section that takes in the slide info. I've attempted to use my child theme functions.php page to remove the original hooks that call the function building this part of the page. I was able to do that. In attempting to recreate that function with my changes and then hook it into the page I was unsuccessful. I've attempted to simply overwrite the various pages using my child theme and that didn't work. I've attempted to use the child themes functions.php page to flat out rewrite the function that builds this part of the page, and that didn't work either. I tried a new functions.php in the admin folder of my child theme. Nothing. The original theme has an admin-functions.php page and I tried overwriting that in my child theme and got nothing. This is really my first time using child themes so I don't have a ton of experience with them. It's also my first attempt and tweaking anything on the backend/admin side. I know I'm supposed to ask for code specific help but I don't even know which of my tactics above is most likely to be successful because I've never done anything like this. Tell me which potential solution to focus on and I'll be happy to supply code in that regard. Thanks in advance. **Edit:**   in the theme files I can edit this function in the admin/settings.php page of my theme to change the number of slides.               function cryout_setting_frontslider2_fn() {     global $parabolas;           $items = array("Custom Slides", "Latest Posts", "Random Posts", "Sticky Posts", "Latest Posts from Category" , "Random Posts from Category", "Specific Posts");     $itemsare = array( __("Custom Slides","parabola"), __("Latest Posts","parabola"), __("Random Posts","parabola"),__("Sticky Posts","parabola"), __("Latest Posts from Category","parabola"), __("Random Posts from Category","parabola"), __("Specific Posts","parabola"));     echo " Slides content:  ";     echo "<select id='parabola_slideType' name='parabola_settings[parabola_slideType]'>";     foreach($items as $id=>$item) {         echo "<option value='$item'";         selected($parabolas['parabola_slideType'],$item);         echo ">$itemsare[$id]</option>";     }     echo "</select>";     echo "
".__("Only the slides with a defined image will become active and visible in the live slider.
When using slides from posts, make sure the selected posts have featured images.
Read the FAQs for more info.","parabola")."
";      ?>

                <?php _e('Latest posts will be loaded into the slider.','parabola'); ?>

                <?php _e('Random posts will be loaded into the slider.','parabola'); ?>

                <?php _e('Latest posts from the category you choose will be loaded in the slider.','parabola'); ?>

                <?php _e('Random posts from the category you choose will be loaded into the slider.','parabola'); ?>

                <?php _e('Only sticky posts will be loaded into the slider.','parabola'); ?>

                <?php _e('List the post IDs you want to display (separated by a comma): ','parabola'); ?>                 <input id='parabola_slideSpecific' name='parabola_settings[parabola_slideSpecific]' size='44' type='text' value='<?php echo esc_attr( $parabolas['parabola_slideSpecific'] ) ?>' />

                <?php _e('
 Choose the category: ','parabola'); ?>                 <select id="parabola_slideCateg" name='parabola_settings[parabola_slideCateg]'>                <option value=""><?php echo esc_attr(__('Select Category','parabola')); ?></option>                <?php echo $parabolas["parabola_slideCateg"];                $categories = get_categories();                foreach ($categories as $category) {                     $option = '<option value="'.$category->category_nicename.'" ';                 $option .= selected($parabolas["parabola_slideCateg"], $category->category_nicename, false).' >';                 $option .= $category->cat_name;                 $option .= ' ('.$category->category_count.')';                 $option .= '</option>';                 echo $option;                } ?>                </select>
                <?php _e('Number of posts to show:','parabola'); ?>                <input id='parabola_slideNumber' name='parabola_settings[parabola_slideNumber]' size='3' type='text' value='<?php echo esc_attr( $parabolas['parabola_slideNumber'] ) ?>' />
                <?php           // CHANGE THE '5' BELOW TO '7' FOR 7 SLIDES           for ($i=1;$i<=5;$i++):           // let's generate the slides           ?>

<?php _e("Slide","parabola");?> <?php echo $i; ?>

<?php _e("Image","parabola");?>
                     <input type="text" value="<?php echo esc_url($parabolas['parabola_sliderimg'.$i]); ?>" name="parabola_settings[parabola_sliderimg<?php echo $i; ?>]"                          id="parabola_sliderimg<?php echo $i; ?>" class="slideimages" />                     <?php _e( 'Select / Upload Image', 'parabola' );?>
 <?php _e("Title","parabola");?>
                     <input id='parabola_slidertitle<?php echo $i; ?>' name='parabola_settings[parabola_slidertitle<?php echo $i; ?>]' size='50' type='text'                          value='<?php echo esc_attr( $parabolas['parabola_slidertitle'.$i] ) ?>' />
 <?php _e("Text","parabola");?>
                     <textarea id='parabola_slidertext<?php echo $i; ?>' name='parabola_settings[parabola_slidertext<?php echo $i; ?>]' rows='3' cols='50'                          type='textarea'><?php echo esc_attr($parabolas['parabola_slidertext'.$i]) ?></textarea>
 <?php _e("Link","parabola");?>
                     <input id='parabola_sliderlink<?php echo $i; ?>' name='parabola_settings[parabola_sliderlink<?php echo $i; ?>]' size='50' type='text'                          value='<?php echo esc_url( $parabolas['parabola_sliderlink'.$i] ) ?>' />

                <?php endfor; ?>

      this above function is called in admin/main.php of the theme               function parabola_init_fn(){     register_setting('parabola_settings', 'parabola_settings', 'parabola_settings_validate');          ...          add_settings_field('parabola_frontslider2', __('Slides','parabola') , 'cryout_setting_frontslider2_fn', __FILE__, 'presentation_section');     }      the `parabola_init_fn` function is called higher up on that same page               add_action('admin_init', 'parabola_init_fn' );      as I said before, I was able to add the following to my child theme functions.php               add_action('init','unhook_parabola_init_fn');     add_action('admin_init', 'parabola_init_fn_new' );          function unhook_parabola_init_fn() {         remove_action('admin_init','parabola_init_fn');     }      this would remove the original sections of the backend page that let me customize the theme but would not load the `parabola_init_fn_new` function that was exactly the same as the `parabola_init_fn` function except for the call to `cryout_setting_frontslider2_fn_new`, which contained my edit to get more slider options in the backend, instead of the original `cryout_setting_frontslider2_fn`. I hope that all makes sense, but I doubt it will. **2nd Edit:** In the functions.php of my child theme I tried to break things down a bit to see where the problem was occuring. First I changed my hooks so that instead of just unhooking the one function I was also rehooking it.               add_action('init','unhook_parabola_init_fn');     add_action('admin_init','parabola_init_fn');          function unhook_parabola_init_fn() {         remove_action('admin_init','parabola_init_fn');     }      My thinking was that this would go get the function and the page would load fine and proper, but that's not what happened. The page doesn't load anything, all white screen. So something went wrong, maybe I need to have `parabola_init_fn` in the functions.php so I tried that. Nothing. Same blank page. Finally, when I change the second hook to `parabola_init_fn_new` is when the page loads at all. The editable section of my page is still gone. I have no idea what's happening. **3rd Edit:** Figured it out. There was another function calling `parabola_init_fn`. I had to add a bunch more stuff to my functions.php page in order to make sure this was pointing in the right place, but it's now working. Thanks for all your help guys.


single_term_title() running before get_the_title()

This is a strange "problem" but I've had this happen on a few installs and I was wondering if anybody could give an explanation on why / how this happens. On a blog category if I code: `<?php echo get_the_title(1).': '.single_term_title(); ?>` Outputted to my screen: `UncategorizedBlog:` On the otherhand, if I do this: `<?php echo get_the_title(1); ?>: <?php single_term_title(); ?>` I get the correct output `Blog: Uncategorized`. I'm not sure if this is a PHP problem or a WordPress or maybe it's something in my code I've messed up along the way. Anyway I was curious as to why it appears that way since I would think order of operations would print the first function first, move onto the concatenation, then proceed to the `single_term_title()` but apparently this is not the case.


Exclude featured image from gallery code stops Lightbox from working

I was looking for a solution to exclude the featured image/thumbnail in each post, so I found this great piece of code and added it to functions.php. It worked perfectly except for one thing: it renders the Lightbox jquery plugin useless. The difference I see in code is this. With the code:                     Without:                     It seems the filter does something to the post_gallery that makes WP not show the Lightbox part (missing rel="lightbox[]"), but I can't figure out why it does that. Reference code in functions.php from here:               function exclude_thumbnail_from_gallery($null, $attr)     {         if (!$thumbnail_ID = get_post_thumbnail_id())             return $null; // no point carrying on if no thumbnail ID              // temporarily remove the filter, otherwise endless loop!         remove_filter('post_gallery', 'exclude_thumbnail_from_gallery');              // pop in our excluded thumbnail         if (!isset($attr['exclude']) || empty($attr['exclude']))             $attr['exclude'] = array($thumbnail_ID);         elseif (is_array($attr['exclude']))             $attr['exclude'][] = $thumbnail_ID;              // now manually invoke the shortcode handler         $gallery = gallery_shortcode($attr);              // add the filter back         add_filter('post_gallery', 'exclude_thumbnail_from_gallery', 10, 2);              // return output to the calling instance of gallery_shortcode()         return $gallery;     }     add_filter('post_gallery', 'exclude_thumbnail_from_gallery', 10, 2);      Thanks a lot in advance! **UPDATE** : I found this http://core.trac.wordpress.org/ticket/14130 it says it adds filter post_gallery_output but I can't figure out what is that I have to modify in the current code to try another solution.


How to add pagination to my code?

I just want to ask how can I add pagination here in this code:               <?php if ( get_option('webly_display_media') == 'on' ){ ?>

                                     <?php                                          $args=array(                                             'showposts' => '7',                                             'category__not_in' => get_option('webly_exlcats_media')                                         );                                         query_posts($args);                                     ?>                                     <?php if (have_posts()) : while (have_posts()) : the_post(); ?>                                         <?php                                              $width = 140;                                             $height = 72;                                             $titletext = get_the_title();                                             $thumbnail = get_thumbnail($width,$height,'project-image',$titletext,$titletext,true,'Media');                                             $thumb = $thumbnail["thumb"];                                             $et_medialink = get_post_meta($post->ID,'et_medialink',true) ? get_post_meta($post->ID,'et_medialink',true) : '';                                             $et_videolink = get_post_meta($post->ID,'et_videolink',true) ? get_post_meta($post->ID,'et_videolink',true) : '';                                         ?>
                                             <?php if ( $et_medialink <> '' ) { ?>                                                 <a href="<?php echo $et_medialink; ?>">                                             <?php } elseif ( $et_videolink <> '' ) { ?>                                                 <a href="<?php echo $et_videolink; ?>" rel="prettyPhoto[media]" class="et-video" title="<?php echo $titletext; ?>">                                             <?php } else { ?>                                                 <a href="<?php echo $thumbnail["fullpath"]; ?>" rel="prettyPhoto[media]" title="<?php echo $titletext; ?>">                                             <?php } ?>                                                     <?php print_thumbnail($thumb, $thumbnail["use_timthumb"], $titletext, $width, $height, 'project-image'); ?>
                                       <?php endwhile; ?>                                     <?php endif; wp_reset_query(); ?>

       My posts has a featured video and currently that code displays 5 featured video base on the category. The problem is, I already have 11 posts in that category but the theme can only display 5 posts so I want to have a pagination for that. Can you help me? Here's the development site http://dev.freelanceu.net/mjl/fitnessadventure/. You can see the above code at the bottom of the content, before the footer.


How to make search for the custom post type?

i tried to figure this out but i can't until know i have new custom post type of `questions` and i have other post types also like `job listing`, `resumes` etc what i want here to make search for the post type questions only here what i done                           <?php global $app_abbr, $header_search; $header_search = true; ?>                 <?php get_header(); ?>                                    <form action="<?php bloginfo('url'); ?>/" method="get" id="searchform">

                                 <input type="hidden" name="questions_search" value="true" />                                 <input type="hidden" name="post_type" value="questions" />                                               <input type="text" id="search" title="" name="s" class="text" placeholder="<?php _e('All Questions and answers'); ?>" value="<?php if (isset($_GET['s'])) echo get_search_query(); ?>" />                                 <button type="submit" title="<?php _e('Go'); ?>" class="submit"><?php _e('Go'); ?></button>

                          </form>      and the search page                               <?php                     global $wp_query, $query_string;                          $term_heading = '';                     $find_posts_in = '';                          $search = get_search_query();                          if ($search) :                         $term_heading = sprintf( __('Searching  for Questions “%s” '), get_search_query());                     else :                         $term_heading = __('Searching  ');                     endif;                               if (is_array($find_posts_in)) :                         $args = array_merge( $wp_query->query,                             array(                                 'post_type' => 'questions',                                 'post__in' => $find_posts_in                             )                         );                     else :                          $args = array_merge( $wp_query->query,                             array(                                 'post_type' => 'questions'                             )                         );                     endif;                     query_posts( $args );                     ?>


onclick open window

I am using AS-PDF plugin in WordPress. In this plugin, For opening new window, I would like to add onclick events in it like that               function as_pdf_link( $strContent ){     global $wp_query;          $strHtml = '
                         post->ID .'"onclick="open(this.href, this.target, 'width=600, height=450, top=200, left=250'); return false;">                                     ' . stripslashes( get_option( 'as_pdf_linktext' ) ) . '
                         ';          return $strContent . $strHtml;      } But It doesn't work. So, please guide me how to do. Thank in advance.


Why doesn't flush_rewrite_rules run on plugin activation?

I'm trying to flush rewrite rules in a plugin and it isn't working. I have to go to permalinks -> save in the admin panel for the rewrites to flush. Can anyone see why?               class SpektrixPlugin {          public function __construct(){         add_filter('query_vars', array($this, 'add_query_vars'));         add_action('init', array($this, 'add_rewrite_rules'));     }          public function activate() {              flush_rewrite_rules();     }          public function deactivate() {              flush_rewrite_rules();     }          public function add_query_vars($vars) {         $vars[] = "event"; // name of the var as seen in the URL         return $vars;     }          public function add_rewrite_rules() {         $page = get_page_by_title( 'Event' );         add_rewrite_rule( 'whats-on/(.+)/?$' , 'index.php?page_id='.$page->ID.'&event=$matches[1]' , 'top' );     }               }          $SpektrixEvents = new SpektrixPlugin;          register_activation_hook( __FILE__, array($SpektrixEvents, 'activate') );     register_deactivation_hook( __FILE__, array($SpektrixEvents, 'deactivate') );


Quote rotator in the sidebar

I like to style some post (bold and link) in the post editor (easy and fun) and categorize it as "quote". Then display it based on a CSS in a sidebar, rotating it, like show 1 each 5 second, randomly. Do you know a plugin the just do that ? thanks in advance


How to modify/extend/override a core method?

This is my first post. In advance, thank you for welcoming me... # Context When you enqueue style, you can output your css link into conditional comments.               global $wp_styles;     wp_enqueue_style("my_styles_ie");     $wp_styles->add_data("my_styles_ie", "conditional", "(lt IE 9) & (!IEMobile)");      It will produce the following code :               <!--[if (lt IE 9) & (!IEMobile)]>         <link rel="stylesheet" href="#" />     <![endif]-->      This is done by the `do_item()` method of the `WP_Styles` class (class.wp_styles.php). # Goal I'd like to add a "anticonditionnal" parameter with the condition value...               $wp_styles->add_data("my_styles_ie", "anticonditional", "(gt IE 8) | (IEMobile)");      to be able to output this ("nested comments"):               <!--[if (gt IE 8) | (IEMobile)]><!-->         <link rel="stylesheet" href="#">     <!--<![endif]-->      I have searched about "how to modify core method" but I didn't find any solution... :( For now, I can do it with a hook but there is no "arguments". Stylesheet and condition are hardcoded...               function antiConditionnal($tag, $handle) {         if('my_styles' == $handle)             $tag = '<!--[if (gt IE 8) | (IEMobile)]><!-->' . "\n" . $tag . '<!--<![endif]-->' . "\n";              return $tag;     }     add_filter( 'style_loader_tag', 'antiConditionnal', 10, 2);      This is mainly for me an opportunity to improve my knowledge and dive deeper into WordPress! Any idea? Thank you... tm


Function to get permalink of custom post type archives?

Is there a function that will return the permalink to a custom post types archives that is available to use in WordPress? Something like: `get_cpt_permalink("events")` which will return `http://example.com/events/` when `has_archive => true` on it. If not what would I need to home brew my own? I'm thinking I would need to read `$wp_rewrite` and use something along the lines of `$wp_rewrite->get_extra_permastruct('events');`


Will A WordPress automatic update harm my website?

Recently I got to know that my Wordpress site is automatically updating itself when a new version of Wordpress is available. I know that this automatic feature is available in Wordpress since sometimes back. But I have some questions about this:   1. Can this be risky in any case?    2. Does it matter how we have installed Wordpress? (e.g plugins and security settings)    3. Does Wordpress have a way to recover our website if anything goes wrong?   4. Does WordPress keep any backup when doing the update?


Detect category choice for posts with multiple categories

On my single template, I wish to show other posts in that category.   Its essential that I use the route they chose, i.e. if they clicked Category 1, then Post A, if Post A is also Categorised as Category 2 and Category 3, I only want to show posts from Category 1 because that is what they originally chose. Is this an option? Is there a way to store some sort of global variable which I can set on my category page, then utilise on my single page?


Error while setting role

I already got code which can change role basis on post count.               <?php            add_action( 'save_post', 'update_roles' );         function update_roles( $post_id ) {                  if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )                 return $post_id;                  // Get the author             $author = wp_get_current_user();                  // Set variables for current user information             $count = count_user_posts( $author->ID );             $current_role = (array) get_user_meta( $author->ID, 'wp_capabilities' );                  get_currentuserinfo();              global $user_level;                  // Do the checks to see if they have the roles and if not update them.             if ( ($user_level != 10) && ( $count > 3 && $count <= 5 ) && ( array_key_exists( 'contributor', $current_role[0] ) ) ) {                 $user_id_role = new WP_User( $author->ID );                 $user_id_role->set_role( 'author' );                  } elseif ( ($user_level != 10) && ( $count > 5 && $count <= 9 ) && ( array_key_exists( 'author', $current_role[0] ) ) ) {                      $user_id_role = new WP_User( $author->ID );                 $user_id_role->set_role( 'editor' );                  } elseif ($user_level != 10){                      $user_id_role = new WP_User( $author->ID );                 $user_id_role->set_role( 'contributor' );                  } return $post_id;              }          ?>      Now I have tested on local environent and it was working but now I dont know why it is giving me error as below.               Warning: array_key_exists() [function.array-key-exists]: The second argument should be either an array or an object in /home/....../themes/..../inc/functions/user-role.php on line 20          Warning: Cannot modify header information - headers already sent by (output started at /home/....../themes/..../inc/functions/user-role.php) in /home/...../wp-includes/functions.php on line 861      Please help me to solve this.


Google Apps login in wordpress

I manage a google apps domain with plenty of users; I would like to join Google apps with a Wordpress based intranet app we're creating. Which level of integration could I expect to achieve? Our hope is to create users in wordpress using their google apps email and let them login using their google apps password, so that they don't need to remember two different passwords. How would you suggest we should implement this?


Version Control: Entire site or just pieces?

I've been using git to track changes in the plugins and themes I've developed for different sites. Each plugin or theme has their own repository in whichever local install of WordPress I happen to be using for that project. This works fine when I'm just working on one solitary plugin or theme. But when I have a local version of an entire site which is a collection of different plugins, themes, WordPress core, etc. Should I be keeping that entire directory under version control? Is there a best practice to always have a collection of repositories for each theme/plugin, or for each client site to have one monolithic repository that includes all the code used in the project (including the latest copy of WordPress via svn.)


Why doesn't my WP Meta Query return any results?

Is it not OK to accept a value from $_GET as the key in a WP Meta Query? I'm not sure why this code doesn't return any results... BOTH the queries for Price as well as bedrooms do not return any results. Is my code incorrect? Any help will be much appreciated..               <?php     if ( get_query_var('paged') ) {     $paged = get_query_var('paged');     } else if ( get_query_var('page') ) {     $paged = get_query_var('page');     } else {     $paged = 1;     }     $args = array(     'post_type' => 'property',     'paged' => $paged     );          if($_GET['beds'] >= 1) {     $args['meta_query'][] = array(     'key' => $_GET['beds'],     'value' => array('pyre_BHK-A','pyre_BHK-B','pyre_BHK-C','pyre_BHK-D','pyre_BHK-E'),     'compare' => 'IN'     );     }          if(($_GET['price-max'] >= 1)&&($_GET['price-min'] >= 1)) {     $args['meta_query'][] = array(     'relation' => 'OR',     array(     'key' => 'pyre_price',     'value' => array($_GET['price-min'],$_GET['price-max']),     'compare' => 'BETWEEN',     'type' => 'numeric'     ),     array(     'key' => 'pyre_pricem',     'value' => array($_GET['price-min'],$_GET['price-max']),     'compare' => 'BETWEEN',     'type' => 'numeric'     )     );     }          query_posts($args);     if(have_posts()):     ?>          <?php     while(have_posts()): the_post();     ?>               <?php get_template_part( 'property-listing' );           // Navigation bar (property-listing.php) ?>          <?php endwhile; ?>          <?php else: ?>
<?php echo of_get_option('search_results_none_title', 'No properties were found which match your search criteria.'); ?>

<?php echo of_get_option('search_results_none_content', 'Try broadening your search to find more results.'); ?>
     <?php endif; ?>


Single loop with dual content area

Is there a way to implement a single loop with dual content area. **E.g. A single loop having 2 of** `<?php the_content(); ?>` **Dinstinguished as shown bellow with video and write-up respectively**               <?php the_content('video'); ?>          <?php the_content('write-up'); ?>


How to solve this without flushing the rewrite rules for each post query the visitor triggers?

Actually I have the problem that I provide a menu link (predefined in theme) to the latest post of a specific custom post type. I achieve this by the following function …               function get_latest_magazine_issue_url() {         global $wpdb;         $query = "SELECT ID FROM {$wpdb->prefix}posts WHERE post_type='magazine_issue' AND post_status='publish' ORDER BY post_date DESC LIMIT 1;";         $result = $wpdb->get_results($query);         if(is_object($result[0])) { return get_permalink($result[0]->ID); }          else { return ''; };     }      … fine til that point – but I recognized, that when I clicked on that link after adding a new cpt post, the link will still grab the post which was the latest when I implemented this link via widget. Is there any way to get around this without a flush_rewrite_rules() call? I wouldn't like to flush that way cause the codex says: http://codex.wordpress.org/Function_Reference/flush_rewrite_rules


How to get the number of posts in a selected category?

I would like to show the number of posts on the category page. How is it possible? I tried to find a solution but no luck.. Thank you!


why do drafts return as part of wp_query?

I have some code as plugin, which I call via AJAX from a page one the site. It gets two drop-down values and uses them in tax_query to fetch some posts. Question: why do **drafts** return amongst results by default? I need to uncomment `'post_status' => 'publish'` to prevent this from happening. User is not logged in, and the doc says > "Default value is 'publish', but if the user is logged in, 'private' is > added. And if the query is run in an admin context, protected statuses are > added too. By default protected statuses are 'future', 'draft' and > 'pending'." Does this mean that drafts considered " _public_ " somehow? These are regular posts, no custom post type stuff here. Or is it tax_query overriding the default behaviour somehow? I'm puzzled. Here is the code of query parameters:                 $args = array(         'posts_per_page' => 5,         //'post_status' => 'publish',         'tax_query' => array(           'relation' => 'AND',           array(             'taxonomy' => 'height_category',             'field' => 'slug',             'terms' => array( $_POST['height'] )           ),           array(             'taxonomy' => 'age_category',             'field' => 'slug',             'terms' => array( $_POST['age'] )           )         )       );


Password Protected Directory Link Shows Maintenance Mode Page

In my WordPress installed directory, I have placed a directory named "Projects". My WordPress site is in maintenance mode with Maintenance Mode Plugin Installed on it. I password protected my "Projects" directory from cPanel, but instead of asking username & password it shows maintenance mode page. Any idea ?


how to publish a feed of posts with a certain custom field value?

In addition to the normal feed that wordpress produces, i need to publish an additional feed of posts that have a certain custom field value. I'm a bit lost on where to start. Any tip?


Why doesn't my Table get created?

I am working on creating a table in the DB for a plugin but cannot figure out why the table is not being created. Here's my code:               global $ds_swoons_db_version;     $ds_swoons_db_version = '1.0';          function ds_swoons_install(){     global $wpdb;          $table_name = $wpdb->prefix . "ds_entry_swoons";              if( $wpdb->get_var("show tables like '$table_name'") != $table_name ):         $sql = "CREATE TABLE IF NOT EXISTS " . $table_name . " (                 id mediumint(9) NOT NULL AUTO_INCREMENT,                 post_id int(9) NOT NULL,                 user_id (9) NOT NULL,                 swoon_status int(1),                 UNIQUE KEY id (id)                 );";         require_once(ABSPATH . 'wp-admin/includes/upgrade.php');         //make the query         dbDelta($sql);         //add db verison number         add_option('ds_swoons_db_version', $ds_swoons_db_version);     endif;          }//end ds_swoons_install          register_activation_hook( __FILE__, 'ds_swoons_install');      I tried to echo the error but get an unexpected output error - probably due to headers being sent already. This is all the code I have so far - just wanted to see if I could create the table before moving on to anything else. Thanx in advance! EDIT ---------------------------------------------------- I figured it out - I did not have the data type declaration for user_id so it never created the table. I changed it and it worked :)


Where is the source of the media items filter

I couldn't find the source in the php files. What is generating the select drop-down for the attachment filters in the media library? ![media items filter](http://i.stack.imgur.com/siVpq.png)


Twenty Eleven: Home Page, View full post of most recent post & Summary of the rest

I am using the Twenty Eleven theme and need to show the full content of the latest post and then show the rest as summary. I'm looking for instructions/help on how to display, on the home page, the full post of the most recent article and then just the summary of the older the posts. For Example (Post #5 being the newest & Post #1 being the oldest): Post #5 (Full Article) Post #4 (Summary) Post #3 (Summary) Post #2 (Summary) Post #1 (Summary) <-- Next Any ideas? Please help!


Custom posts type for individual pages?

I am trying to make a wordpress site with an idiot-proof backend CMS. I have built several relatively small wordpress sites, but now have moved on to a larger project and want to do it _right_. There will be several (maybe as much as 10+) pages each with unique structures and elements (different numbers of pictures, and text-content areas). There will be maybe a couple dozen other pages with more standard layouts (just some text into a template). Ideally, I would want the "edit page" area of each 'unique' page to have its own unique set-up. For Example, heres a few sample pages: Home page   * List item   * 2 sections of text   * 6 photos with captions (captions are split in 2 sections each for 2 fonts and a line break) About page   * 2 images (no captions)   * 1 main text section   * 1 video Videos page   * 2 text sections   * 1 picture   * any number of videos Now its pretty clear to me that for the videos page, I should create a custom- post-type video, where the user can put in the url for a YouTube video, some descriptive text etc... and then pull all of those video posts into my videos page. What is unclear to me is whether I should make a 'homepage' custom-post-type with only one post (the homepage) and do the same thing for other pages with unique elements/layouts. I hope this is clear enough, I can elaborate more or create some images of what I have in mind, but this seems to be getting rather lengthy.


How do I urlencode() the blog description?

I have a series of share buttons, each one using a short URL (using Ozh's Yourls plugin) and a page title (as found on urlencoding of the_title() doesn't work?) and some require a description. How do I put the blog description, encoded correctly, into my URL?


How to redirect unattached image attachments

I'm currently redirecting all attachment images to their parent post with the following function:               function attachment_redirect() {         global $post;         if ( is_attachment() && isset( $post->post_parent ) && is_numeric( $post->post_parent ) && ( $post->post_parent != 0 ) ) {             wp_redirect( get_permalink( $post->post_parent ), 301 );             exit();         }     }     add_action( 'template_redirect', 'attachment_redirect' );      How can I redirect all images that have been uploaded to the media library but remain 'unattached'? My aim is to redirect these images to the homepage.


How to tell if the user is an admin?

I need to show some info only to admins visiting a page, so I need a conditional tag to identify them. So far I have found:               <?php if ( current_user_can('manage_options') ): ?>      is this the correct function?


Year based WP Query

I am am having a strange issue, trying to get year based posts in wp_query, when i do directly, 'year' => '2014' it works fine, but i have the year stored in a variable, $year, then i do 'year' => $year; it shows all posts, did echo of $year, shows 2014 here is the complete code I am using..               global $paged;     if( get_query_var( 'paged' ) )         $my_page = get_query_var( 'paged' );     else {         if( get_query_var( 'page' ) )             $my_page = get_query_var( 'page' );         else             $my_page = 1;         set_query_var( 'paged', $my_page );         $paged = $my_page;     }          $setyear = '2014';          $args = array(         'post_type' => 'news_posts',         'year'  => $setyear,         'tax_query' => array(             array(                 'taxonomy' => 'news_category',                 'field' => 'slug',                 'terms' => 'press-releases'             )         ),         'paged' => $my_page     );      Thanks.


get next next post in single.php

I really need your help. in my single.php I had to get the next post in the same category (which i already have by: $in_same_cat = true; $excluded_categories = ''; $previous = false; $next_post = get_adjacent_post($in_same_cat,$excluded_categories,$previous);) now I need the **next next** post and also in the opposite direction **previous previous** post thanx


Translate third party plugin and save translation files in custom theme

I'm using Codestyling Localization and I want to translate a plugin and I want the translation files to be saved in the translation directory in the theme I'm building and not in the plugins directory. Is this possible? I have tried `load_plugin_textdomain` and `load_textdomain` but that doesn't seem to work.               // Add localization     load_theme_textdomain( 'my_theme', $translation_directory );          $domain = 'other_plugin';     $locale = apply_filters('plugin_locale', get_locale(), $domain);     load_textdomain( $domain, WP_LANG_DIR.'/'.$domain.'/languages/'.$domain.'-'.$locale.'.mo');     load_plugin_textdomain( $domain, FALSE, $translation_directory );


What do I need jQuery for?

What do you think of killing jQuery in the public facing WP site? Isn't it useless and making for slower page loading? What's the best way to get rid of it?


Files empty after moving with FTP

I have a strange bug within my Wordpress theme. After I copy normal files from my local machine (whatever file, functions.php, styles.css or any other) the file gets empty on the server, with no content and I can see the size of 0mb. On the backend, wp-admin works normally, I have previousely received some caching error but that its. Any ideas? P.s. I am using WP 3.1


How to mask url of a specific page without affecting seo

What I'm looking to do is exactly this and/or this. What's holding me back is my fear of losing all the SEO traffic my posts at site.com/blog/post have already acquired. Would implementing this fix negatively affect the page rankings of my posts and if so, by how much?


Why is my AJAX call not working?

I have similar code working from within a theme's functions.php file, but I want to move it to a plugin. I've assembled the following but for some reason, this method is having trouble at the AJAX call and always returns zero. The intention here is that the form will be on the front-end and usable by either logged-in or NOT logged-in users. Here's my plugin code:               /*     Plugin Name: AAA Hello World     Plugin URI: http://helloworld.com     Description: AJAX response to form submission     Version: 1.0     Author: John Doe     Author URI: http://helloworld.com     */          class RespondToMyClicks {            function __construct() {              add_action( 'wp_enqueue_scripts', array( &$this, 'click_response_styles' ) );         add_action( 'wp_enqueue_scripts', array( &$this, 'click_response_scripts' ) );              if( is_admin() ) {           add_action( 'wp_ajax_the_ajax_hook', array( &$this, 'process_clicky_form' ) );           add_action( 'wp_ajax_nopriv_the_ajax_hook', array( &$this, 'process_clicky_form' ) );         }              add_shortcode( 'click_response_form', array( &$this, 'click_response_form' ) );            }            public function click_response_styles() {              wp_register_style( 'respond-to-my-clicks', plugins_url( dirname( plugin_basename( __FILE__ ) ) . '/styles.css' ) );         wp_enqueue_style( 'respond-to-my-clicks' );            }            public function click_response_scripts() {              wp_enqueue_script( 'respond-to-my-clicks', plugin_dir_url( __FILE__ ) . 'ajax.js', array( 'jquery' ) );         wp_localize_script( 'respond-to-my-clicks', 'the_ajax_script', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) ) );            }            public function process_clicky_form() {         if( !empty( $_POST ) && wp_verify_nonce( $_POST['post_filtration'], 'post_filter_action' ) ) {           echo "Hello World";           die();         }       }            public function click_response_form() {         $the_form = '<form id="theForm" method="post" action="">' .          wp_nonce_field( 'post_filter_action', 'post_filtration' ) .          '<input name="action" type="hidden" value="the_ajax_hook" />             <input type="checkbox" name="change_me"  value="" onChange="submit_me();" /> Click me for a response         </form>

';         return $the_form;       }          }          new RespondToMyClicks();      And here's my Javascript file code:                   function submit_me() {                  jQuery("#response_area").fadeOut("slow");                  jQuery.post(the_ajax_script.ajaxurl,              jQuery("#theForm").serialize(),                 function(response_from_the_action_function){                     jQuery("#response_area").html(response_from_the_action_function).fadeIn("fast");                 }             )              }      I've been looking at this too long and have tried different variations of code so hopefully someone can point out the obvious cuz I'm just plain missing it. Thanks!


Template for custom post type shows all posts instead of just one

I wrote a simple plugin to create a custom post type named "people":               add_action( 'init', 'create_person' );          function create_person() {         register_post_type( 'people',             array(                 'labels' => array(                     'name' => 'People',                     'singular_name' => 'Person',                     'add_new' => 'Add New',                     'add_new_item' => 'Add New Person',                     'edit' => 'Edit',                     'edit_item' => 'Edit Person',                     'new_item' => 'New Person',                     'view' => 'View',                     'view_item' => 'View Person',                     'search_items' => 'Search People',                     'not_found' => 'No person found',                     'not_found_in_trash' => 'No people found in trash',                     'parent' => 'Parent Person'                 ),                      'public' => true,                 'menu_position' => null,                 'supports' => array( 'title', 'editor', 'comments', 'thumbnail', 'custom-fields' ),                 'taxonomies' => array( '' ),                 'menu_icon' => plugins_url( 'images/people_icon.png', __FILE__ ),                 'publicly_queryable' => true,                 'show_ui' => true,                  'show_in_menu' => true,                  'query_var' => true,                 'rewrite' => array( 'slug' => 'people','with_front' => FALSE),                 'capability_type' => 'post',                 'hierarchical' => false,                 'has_archive' => true             )         );     }      And added a template called single-person.php to display the custom post type. This filter is in the same file as the code above:               add_filter( 'template_include', 'include_template_people', 1 );          function include_template_people( $template_path ) {         if ( get_post_type() == 'people' ) {             if ( is_single() ) {                 // checks if the file exists in the theme first,                 // otherwise serve the file from the plugin                 if ( $theme_file = locate_template( array ( 'single-people.php' ) ) ) {                     $template_path = $theme_file;                 } else {                     $template_path = plugin_dir_path( __FILE__ ) . '/single-people.php';                 }             }         }         return $template_path;     }      Then there is the actual template here:               <?php      /*Template Name: New Template      */          get_header(); ?>

         <?php         $mypost = array( 'post_type' => 'people', );         $loop = new WP_Query( $mypost );         ?>         <?php while ( $loop->have_posts() ) : $loop->the_post();?>             <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>

                             <?php the_post_thumbnail( array( 300, 300 ) ); ?>

<?php the_title(); ?>

                             <?php echo get_the_term_list( $id, 'roles', '', ', ', '' ); ?>

<?php the_content(); ?>

              <?php endwhile; ?>

     <?php wp_reset_query(); ?>     <?php get_footer(); ?>      UPDATED: I changed the question a bit. I removed a piece of code that I had added. The problem with this template is that when I go to the URL:               mysite.com/people/firstname-lastname      I expect to only get the post of type 'people' which has the slug "firstname- lastname". Instead, all the posts of type 'people' show up on the page. How can I change this so that only the single 'post' is displayed?


wp_get_attachment_image_src() does not return what I want

I got this annoying issue I can't solve :               if( $meta1 = '' && $meta2 = '' ) {      $image_attributes = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), my_own_size_function());     echo  $image_attributes[0];     } elseif(  $meta1 != '' ) {          echo $meta1;      } elseif ( $meta2  != '' ){         $image_attributes = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), my_own_size_function() );         echo $image_attributes[0];     } else {         echo "ko";     }      when I print_r `my_own_size_function()` I get an array like this :               Array     (          [0] => 600          [1] => 400     )      But when I print_r `$image_attributes`I get another result :               Array     (         [0] => http://localhost/wordpress/wp-content/uploads/2013/07/my_image.jpg         [1] => 200         [2] => 150         [3] =>      )      Any idea of what can be the reason for this? Thanks in advance.


How to get all the terms of a post

Here is my code so far:               $terms = wp_get_post_terms($event->ID, 'speakers', array("fields" => "all"));     print_r($terms);      It displays this:               Array (         [0] => stdClass Object (                [term_id] => 64                [name] => Apostle Dr. N Suppaya                [slug] => apostle-dr-n-suppaya                [term_group] => 0                [term_taxonomy_id] => 64                [taxonomy] => speakers               [description] => Apostle Dr. N Suppaya, God called him to the ministry, anointed him and told him to bring love, joy and peace of Jesus Christ to the world. In 1986, Apostle Suppaya received the Apostolic calling from God when God told him to build a Church which will be an instrument in building the Kingdom of God through evangelism and missions to the unsaved. This gave the birth to Jesus Lives Church. God has been blessing him with great miracles to testify the glory of God through his ministerial exposures.                [parent] => 0                [count] => 2 )              [1] => stdClass Object (                [term_id] => 61                [name] => Pastor Lynette Teo                [slug] => ps-lynette-teo               [term_group] => 0               [term_taxonomy_id] => 61               [taxonomy] => speakers               [description] => Pastor Lynette Teo graduated from RHEMA Bible Training Centre Singapore is married to Kevin and both are currently instructors at RBTCS, with a strong passion to teach and equip believers in Singapore and Asia in order to further God’s purposes and plans in advancing His Kingdom. They have also ministered in bible schools and churches in various parts of Asia including Malaysia, Indonesia, Thailand and Myanmar. They serve as leaders in their local church and are actively involved in areas of mentoring and discipleship. Lynette also serves in the prayer as well as worship ministries.                   [parent] => 0                [count] => 1         )      )       How can I echo just name and description?


Display one post in different formats conditionally

I think I just coded myself into a corner. I am setting up a page with an image. The image is an imagemap with lots of links. When you click on the link, it opens a post in a colorbox. So far I have managed to get this part working using a combination of the Lightbox Plus and Post Template plugins. Unfortunately this involves assigning each post to a specific template. The template simply removes the title/image/menu. But this permanently alters the post display. I need to post to still show the full header if it is accessed through the normal menu or from a Google search. How can I display a post differently based on how it is accessed? OR - how can I insert just the post content into the colorbox window without using a custom page or post template?


what's the meaning of the field wp_capabilities in table wp_usermeta

I am new to wordpress, in table `wp_usermeta` I notice that we have a row               meta_key                meta_value     wp_capabilities       a:1:{s:13:"administrator";b:1;}      First, what's the meaning of meta_value `a:1:{s:13:"administrator";b:1;}` , where can I found the exactly explanation of this filed ? Or I what to know all about the `role` `user` `Capabilities` , where can I get these information. Second, how can I create new roles via `wordpress's API` by code Thanks in advanced.


Custom Post Type and Taxonomy URL rewrite

I'm creating custom theme for my personal website using Wordpress 3.5.1. I have problem with the WordPress custom post type and taxonomy, here's the detail:   * custom post type name: `articles`   * taxonomy name: `article-categories`   * rewrite slug: `articles` (same with my cpt) Currently my URL is like this:   * `example.com/articles` --> `archive-articles.php` (it works)   * `example.com/articles/taxo-parent` --> `taxonomy.php` (it works)   * `example.com/articles/taxo-child` --> `taxonomy.php` (it works)   * `example.com/articles/post-title` --> I use `single-articles.php`, it doesn't work I want my URL to be like this:   * `example.com/articles`   * `example.com/articles/taxo-parent`   * `example.com/articles/taxo-parent/taxo-child`   * `example.com/articles/taxo-parent/taxo-child/post-title` It's been a week working with this case and search / reading post from google but still have no luck, really appreciate if you guys could help me. Thanks EDIT: I use WP Custom Post Type UI plugin to create custom post type and custom taxonomy


How to display custom post type only on a certain page?

I have created a custom post type called 'project'. But how do I get the custom post types to display only on my main template? It's a one page website and I don't want it to direct the visitor to a second page. Wordpress v. 3.5.1                <?php          function my_custom_post_project() {     $labels = array(         'name'               => _x( 'Projects', 'post type general name' ),         'singular_name'      => _x( 'Project', 'post type singular name' ),         'add_new'            => _x( 'Add New', 'project' ),         'add_new_item'       => __( 'Add New Project' ),         'edit_item'          => __( 'Edit Project' ),         'new_item'           => __( 'New Project' ),         'all_items'          => __( 'All Projects' ),         'view_item'          => __( 'View Project' ),         'search_items'       => __( 'Search Projects' ),         'not_found'          => __( 'No projects found' ),         'not_found_in_trash' => __( 'No projects found in the Trash' ),         'parent_item_colon'  => '',         'menu_name'          => 'Projects'     );          $args = array(         'labels'        => $labels,         'description'   => 'Holds my projects and project specific data',         'public'        => true,         'menu_position' => 5,         'supports'      => array( 'title','editor', 'excerpt'),         'has_archive'   => false,                 'rewrite' => array('slug'=>'/','with_front'=>false),     );     register_post_type( 'project', $args );     }          add_action( 'init', 'my_custom_post_project' );          function my_taxonomies_project() {     $labels = array(         'name'              => _x( 'Project Categories', 'taxonomy general name'    ),         'singular_name'     => _x( 'Project Category', 'taxonomy singular name' ),         'search_items'      => __( 'Search Project Categories' ),         'all_items'         => __( 'All Project Categories' ),         'parent_item'       => __( 'Parent Project Category' ),         'parent_item_colon' => __( 'Parent Project Category:' ),         'edit_item'         => __( 'Edit Project Category' ),         'update_item'       => __( 'Update Project Category' ),         'add_new_item'      => __( 'Add New Project Category' ),         'new_item_name'     => __( 'New Project Category' ),         'menu_name'         => __( 'Project Categories' ),     );     $args = array(         'labels' => $labels,         'hierarchical' => true,     );     register_taxonomy( 'product_category', 'project', $args );      }      add_action( 'init', 'my_taxonomies_project', 0 );      I now changed the code in index.php:                  <?php get_header(); ?>                   <div id="posts" class="row isotope ">          <!-- Start Project -->         <?php                $args = array(        'post_type' => 'project'        );        $projects = new WP_Query($args);        if ($projects->have_posts()) {        while ($projects->have_posts()) {        $projects->the_post();        the_title();         get_the_content();          }        }              ?>        </div>              <?php get_sidebar(); ?>         <?php get_footer(); ?>      The title is brought in but for some reason with a height of 0px. Is this related to the code or is it a completely different matter? Also the content from the editors metabox is not showing.


Edit php files in subdirs in a child theme

I want to change a php file in a subdir of my theme folder. The path to that specific file is:   `/includes/sf-content-display/sf-post-formats.php` I copied the file within the subdirs in my child theme and made the changes. It seems, if I read some articles, that I have to hook a selfmade function in a file _functions.php_ in the child theme. I did the folowing:               function require_once_child() {         require_once('includes/sf-content-display/sf-post-formats.php');         }          function require_once_child() {         remove_action( 'init', 'require_once' );         add_action( 'init', 'require_once_child' );     }     add_action( 'init', 'require_once_child' );      Result is an error: > Fatal error: Cannot redeclare require_once_child() (previously declared in > /www/htdocs/keltenwo/wp/wp-content/themes/flexform-child/functions.php:3) in > /www/htdocs/keltenwo/wp/wp-content/themes/flexform-child/functions.php on > line 9 Any suggestions?


Sidebar Thumbs Squished?

My Thumbnails seem squished for some reason even though I copied the code from some thumbnails I have that seem to be working fine. The code that works: in index.php               <a href="<?php the_permalink(); ?>">     <?php the_post_thumbnail( 'category-thumb',array('title' => "")); ?>           in functions.php               //Main Thumbnail Size     if ( function_exists( 'add_image_size' ) ) {         add_image_size( 'category-thumb', 192, 134 );     }      The thumbs above work fine, resizing the main image to 192x134 without a problem. The code below does not work. in sidebar.php
         <a class="sidebar-thumb" href="<?php the_permalink(); ?>"><?php the_post_thumbnail( 'sidebar-thumb',array('title' => "")); ?>                <a class="sidebar-link" href="<?php the_permalink(); ?>"><?php the_title(); ?>
      in functions.php               //Sidebar Thumbnail Size     if ( function_exists( 'add_image_size' ) ) {         add_image_size( 'sidebar-thumb', 47, 47 );     }      What did I do incorrectly?


how do I add role and capability after I create a new user

I have a simple requirement:               1. create a user     2. create a role for the user     3. add capability for the role      First, create a new user               $uid = wp_insert_user($userdata);      Second & Third, create a new role and adding capability on it               add_role( $role, $display_name, $capabilities )      How can I make the relationship between the role and the user ?


How to count number of functions attached to an action hook?

I have some actions like this                   function simple_notification() {         echo '
This is a notification
';         }         add_action( 'site_notices', 'simple_notification' );              function simple_notification2() {         echo '
This is a notification
';         }         add_action( 'site_notices', 'simple_notification2' );              function simple_notification3() {         echo '
This is a notification
';         }         add_action( 'site_notices', 'simple_notification3' );      Now i'm displaying those action by calling `do_action` in my template               <?php do_action('site_notices'); ?>      I would like to display notice count near a menu link called `notifications` Can anyone tell me how to calculate it? ## Update: As you can see, three notices displayed when i use `do_action('site_notices');` So I want to display in the menu like `notifications (3)`


Creating custom field with drop down on new post page

I Am trying to create a default custom field drop down with pre populated values from the DB to be shown while creating a new Post or editing a existing post. I am aware about how to add a single custom field and have added few as follows               add_action('wp_insert_post', 'set_default_custom_fields');      function set_default_custom_fields($post_id) {     if ( $_GET['post_type'] != 'page' ) {     add_post_meta($post_id, 'email', 'xyz@mail.com', true);     }     }      This is working fine for me and i am able to see custom field with default value but i am not sure how to add a drop down in place of single text field, i tried something like this but seems like its not working.                add_action('wp_insert_post', 'set_default_custom_fields');        function set_default_custom_fields($post_id) {         if ( $_GET['post_type'] != 'page' ) {     <select name="voodoo_dropdown" id="voodoo_dropdown">             <option<?php selected( add_post_meta($post->ID, 'voodoo_dropdown', true), 'USA' ); ?>>USA</option>             <option<?php selected( add_post_meta($post->ID, 'voodoo_dropdown', true), 'Canada' ); ?>>Canada</option>             <option<?php selected( add_post_meta($post->ID, 'voodoo_dropdown', true), 'Mexico' ); ?>>Mexico</option>             </select>     }     return ;     }      Due to my lack of knowledge i am not sure where i am doing wrong or what needs to be done to accomplish this task


The use of including upgrade.php when building custom queries

I started building a plugin in which I need to build some custom queries with `wpdb` object. It's the first time I use it. So I checked out how to use it. I watched some examples and there is something which is messing up my mind : `upgrade.php` Actually when I create a custom query, this one only works when I include `upgrade.php` this way :               require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );     $custom_posts = $wpdb->get_results( 'SELECT * FROM ' . self::TABLE . '', OBJECT_K );     $wpdb->show_errors();     echo $wpdb->last_query;     return $custom_posts;      This is just one of the method's example I can privide. What is the use of `upgrade.php` ? I mean, if I don't put it, the query doesn't work. Could someone explain, please, cause there's nothing in the codex concerning that. Am I really oblidged to use it ? why ? How ? Thanks UPDATE : Here is the complete code.               /**      * On activate or uninstall plugin      */     register_activation_hook( __FILE__, array( 'Cpt', 'init' ) );     register_deactivation_hook( __FILE__, array( 'Cpt', 'uninit' ) );     register_uninstall_hook( __FILE__, array( 'Cpt', 'uninit' ) );          global $wpdb;          class Cpt     {              CONST TABLE = 'cpt';              /**          * Constructor          */         public function init()         {             /**              * Creation table for cpt              */             $sql = "CREATE TABLE IF NOT EXISTS `" . self::TABLE . "` (               id mediumint(9) NOT NULL AUTO_INCREMENT,               time datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,               name tinytext NOT NULL,               UNIQUE KEY id (id)             );";             require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );             $wpdb->query($sql);                  self::convert_to('post', 'custom');         }              public function uninit() {             /**              * Delete table for cpt              */             require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );             //$wpdb->query("DROP TABLE IF EXISTS `cpt`;");             //$this->delete_cpt("Custom post 1");         }              /**          * Add a custom post type          */         public function add_cpt($name) {             /**              * Add a single data              */             $time = (string)date('dmY');             require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );             $wpdb->insert(                  self::TABLE,                  array(                     'time'=>$time,                      'name'=>$name                 )              );             /*$wpdb->show_errors();             echo $wpdb->last_query;             die();*/         }              /**          * Delete a custom post type          */         public function delete_cpt($name) {             /**              * delete a single data              */             require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );             $wpdb->delete(                  self::TABLE,                  array(                      'name'=>$name                  )              );             $wpdb->show_errors();             echo $wpdb->last_query;             die();         }              /**          * Get all custom post types          */         public static function get_ctps() {             /**              * delete a single data              */             require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );             $custom_posts = $wpdb->get_results( 'SELECT * FROM ' . self::TABLE . '', OBJECT_K );             $wpdb->show_errors();             echo $wpdb->last_query;             return $custom_posts;         }              /**          * Get a single custom post type          */         public function get_ctp($name) {             /**              * get a single data              */             require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );             $custom_post = $wpdb->get_results( 'SELECT name FROM ' . self::TABLE . ' WHERE name = $name', OBJECT_K );             $wpdb->show_errors();             echo $wpdb->last_query;             print_r($custom_post);             //return $custom_post;         }              /**          * Post type conversion          */         public static function convert_to($from, $to) {                  // Get the posts of the type $from             require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );             $wpdb->update( 'wp_posts', array('post_type'=>$to), array('post_type'=>$from) );             $wpdb->show_errors();             echo $wpdb->last_query;         }              /**          * Generate admin menu with all custom post types          */         public function generate_menu() {                  $custom_posts = self::get_ctps();          }     }


Making featured image to show on home page

I am working on twenty twelve theme. Whenever I post an image gallery, it shows all of images including featured image on front page same as it looks inside. I wanted it to just show featured image on home page instead of showing all. I tried but no success. Any help appreciated!! Thanks


How to bypass the Easy Digital Downloads checkout process?

I've decided to use Easy Digital Downloads as a base to create a secure download area for a client. The client will be uploading general files such as .pdf's and word documents for their members. What I'd like to do is bypass the checkout process of Easy Digital Downloads so users can download a file straight away, without having to first add a download to their cart, checking out, and then receiving the email with the download link. Is anyone familiar with EDD and how this can be achieved?


How would I remove an inline googleAPI font script in the the parent theme header.php?

Is there any way to remove the function call to the googlefontapi font in the parent header.php file besides copying the parent header.php file to the child theme and then overriding it and delete the line of codes? I was searching for a way to dequeue the call but it doesn't have a handle and it's an inline script in the parent theme header.php file.               (function() {         var wf = document.createElement('script');         wf.src = ('https:' == document.location.protocol ? 'https' : 'http') +           '://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js';         wf.type = 'text/javascript';         wf.async = 'true';         var s = document.getElementsByTagName('script')[0];         s.parentNode.insertBefore(wf, s);     })();      Thanks in advance.


get_posts from a category id doesn't work

I use the following code to get portfolio type posts from category id, but it doesn't work.               $args = array( 'numberposts' => $items, 'post_type'=>'portfolio','orderby' => 'date','order'=>'DESC','category' => 5 );     $posts = get_posts($args);     foreach($posts as $post){         setup_postdata($post);         $return_html='......';     }      however,if I leave the category id empty, it' fine and will show all categories posts. I'm sure that there are many posts under category 5. Thanks in advance.


How do I delete element from a serialized array upon deletion of a post?

I want to delete an element (post id) from a serialized array associated with a specific meta_key. The following screenshot tells the whole story. ![enter image description here](http://i.stack.imgur.com/XVPTX.png) What you're seeing are, post ids saved in a serialized array. Upon deletion of any post the id of the post should be removed from meta_value where meta_key is "whatever". I want to wrap unset for elements (both key and value) inside a function as shown below. Sounds complex to me.               add_action('before_delete_post', 'upon_deleting_post');     function upon_deleting_post($post_id){     ....     };


Normal page, can select named page template, but page.php used instead

In other words, for some pages, I set the named template and update, and the change carries through to the front-end. For other pages, wp-admin shows the changed template name, but that template is not shown but instead the default page.php. select * from wp_postmeta where meta_key = '_wp_page_template' and post_id=756               meta_id post_id meta_key    meta_value     38002   756 _wp_page_template   page-map.php      In header.php, it seems to fall back on page.php instead of reading the template file name:
     <?php         echo '';         if (is_front_page()) echo 'front page. ';         if (is_page()) echo 'page. ';             echo 'template: '.basename(get_page_template()).'.';         $page_object = get_queried_object();         $page_id     = get_queried_object_id();         echo 'page id: '.$page_id.'.';         echo 'post id: '.$post->ID.'.';         echo '';     ?>      The printout from this echo is:               template: page.php.page id: 0.post id: 6863.      In other words (since the front page and page checks give empty string), it doesn't consider it a page at all, even though it's under Pages in wp-admin. Also, the post id is wrong, it should be 756 and not 6863 which is the post id of the last post in the loop. It does execute content.php but not index.php. Also, it displays archived posts, and it does execute archive.php. I have yet to find out if it used any template at all, unless archive.php is a template. It obviously exists as a page in the database, and the permalink is correct for the page. But somehow WP doesn't think it's a page at all. There is a post_type named the same as the permalink slug. Does that take precedence and if so how do I make it not take precedence?


Get permalink to page?

I know this is going to be simple but I can't work it out. I want to create a nav in the footer listing each page and it's child pages. It will look something like this

Parent

Child One

Child Two

Child Three

        I'm using this code to do it.
             <?php             $args = array(                 'sort_column' => 'menu_order',                 'parent' => 0,                 );             $pages = get_pages($args);             foreach($pages as $page){                 ?>

                             <a href="<?php echo $page->permalink; ?>"><?php echo $page->post_title;?>
                     <?php                       wp_list_pages('title_li=&depth=1&child_of='.$page->ID.'');                     ?>
                 <?php                 }             ?>
      My problem is getting the permalink to the parent page.                   <a href="<?php echo $page->permalink; ?>"><?php echo $page->post_title;?>        How do I get the permalink in this situation?


How do I make archives.php for one category only?

I have a basic archives.php file. I was trying to get it to display only posts from category 1. When I do query_posts('cat=1'), the URL is then ignored and all posts in category 1 are displayed. For example, lets say I have one post in category 1: it's called "testing post" and is dated November, 1, 2012. Lets say I have another post in category 5 dated April 2, 2012. With the current archives.php (using the query posts for cat 1) the URL: http://testing.com/2012/04 resolves to show all posts within category 1. No good, since the post is dated November, and the URL is querying for April (04). The archives.php will resolve http://testing.com/2012/04 and http://testing.com/2012/11 as each of those months have a post in them (albeit not from category 1), it will not however resolve http://testing.com/2012/09 as that month doesn't have any posts (category 1 or otherwise) How can I make the archives.php file query for the current month (whatever is in the URL) but only display posts in category 1? Asked another way, how can I make http://testing.com/2012/04 come up with a "sorry there are no posts here" message, like in http://testing.com/2012/09 while http://testing.com/2012/11 still displays the one post from category 1?


How to sort Custom Fields by a value

i use below code in home page for show a table of custom fields. but i don't know how sort this table by duration value.               <table>     <?php while(have_posts()): the_post() ; ?>     <?php if (get_post_meta($post->ID, 'duration', true)>'1') :  { ?>     <tr>    <?php global $wp_query; $postid = $wp_query->post->ID; ?>         <td>    <?php echo get_post_meta($postid, 'target', true); ?> </td>         <td>    <?php echo get_post_meta($postid, 'price', true); ?> </td>         <td>    <?php echo get_post_meta($postid, 'duration', true); ?> </td>         <?php wp_reset_query(); ?> </tr>     <?php } ?>     <?php endif; ?>     <?php endwhile; ?>        </table>


How to number the posts (ie #1, #2, #3) in a wp_query?

What is the best way to display the appearance number of a post in a query? For example, if a post is the first listed print #1. If it is third, print #3. Any direction is appreciated!


WP-Markdown treating java generics like HTML tags

With some Java generic code in a code block, ie:               List<Integer> l = new ArrayList<Integer>();      WP-Markdown was treating as HTML, and no matter what I did, the code above got turned into something like               List<Integer> l = new ArrayList</Integer><Integer>();</Integer>      Is there any way to get WP Markdown to behave better with this kind of code? Gist and (clearly) Stackexchange don't have this problem.