Website Loading Very Slow, Each Time Different File Takes Very Long To Load

My website's been very slow lately, and I've been checking my site in some of the response time checker websites. And they show over 20-30 seconds to load my website, so it is very bad right now. The website URL is catloversmag.com. I've noticed that each time I do a response test, there are a few files that takes forever to load. And that file changes every time.. A screenshot of the response test is here: http://i.imgur.com/RY9QZXs.png I also saw some errors: http://i.imgur.com/vSEBALS.png I'm not asking anyone to fix this for me, but I would really appreciate it if someone could tell me what is causing such a slow response time. I am using Mediatemple WordPress Premium hosting so I doubt it's because of my hosting. If anyone could please find out what the problem is, it would be really helpful. Even if I can't fix it myself, at least I would know what to tell if I have to use a freelancer.. This is a very important project for me and I really wish someone could help me. If someone would like to fix this personally, I would be happy to pay for the service as long as this can be fixed. Thank you, Andrew


How to add a media with PHP

I have more than 1000 pictures on my webserver, uploaded with FTP in a local folder ( `/home/chris/pictures` ) Is there a way to add them as a well known media to wordpress in PHP and get their id?               while ( $the_query->have_posts() ) : $the_query->the_post();         $post_id = get_the_ID();         $filemakerID = get_post_meta($post_id, 'filemaker_id', true);              $file['url']='/home/chris/picture_export/'.$filemakerID.'.jpeg';         $file['type'] = 'image/jpeg';              //THE DREAMED FUNCTION WOULD BE USED THIS WAY         $photo_id = awesome_function( $file, $post_id);              add_post_meta($post_id, 'photo', $photo_id );     }      As you noticed, my photo is used in a custom field `photo` as well. After hours on google dans codex, I noticed how poorly documented these functions are. Maybe I just could not figure out the correct keywords to search.


Multisite mu-plugins site-specific directory

Is it possible to have a must-use directory within the multisite system that is specific to each individual site?


Admins can't edit each other's posts

After I imported content from another wordpress site using the WXR export/import tools, my admins can't edit each other's posts. This is really aggravating because I can't figure out how to change this. And it doesn't just related to imported content. I can create two brand new admins, each one creates an entry, but neither one can edit the other's posts. On the post listing page, it doesn't even show an Edit link on or below the title, and there's no checkbox for bulk editing, if the logged-in user isn't the author. I don't have this problem with pages, but it does effect any Custom Post Types set as 'capability_type' => 'post' I have no idea how this happened or how to undo it. Please help before I pull all my hair out.


title tag for custom post type remove taxonomy name from title tag

So it appears I am missing a vital pice of information somehow to make my custom post type title tag behave. everything else works fine. my current - simple - scenario is this : wordpress 3.8, twentytwelve theme, wpizza plugin (I'm the author of this , so that's what the questions relates to really), nothing else I registered the wppizza custom post type and taxonomies like so:                               /*******************************************************                         [register custom post type]                     ******************************************************/                     public function wppizza_register_custom_posttypes(){                         $labels = array(                             'name'               => __( 'Menu Items', $this->pluginLocale),                             'singular_name'      => __( 'WPPizza Menu Item', $this->pluginLocale ),                             'add_new'            => __( 'Add New',  $this->pluginLocale ),                             'add_new_item'       => __( 'Add New Menu Item',$this->pluginLocale ),                             'edit'               => __( 'Edit', $this->pluginLocale ),                             'edit_item'          => __( 'Edit Menu Item',$this->pluginLocale ),                             'new_item'           => __( 'New Menu Item',$this->pluginLocale ),                             'all_items'          => __( 'All Menu Items',$this->pluginLocale ),                             'view'               => __( 'View', $this->pluginLocale ),                             'view_item'          => __( 'View Menu Items',$this->pluginLocale ),                             'search_items'       => __( 'Search Menu Items',$this->pluginLocale ),                             'not_found'          => __( 'No items found',$this->pluginLocale ),                             'not_found_in_trash' => __( 'No items found in the Trash',$this->pluginLocale ),                             'parent_item_colon'  => '',                             'menu_name'          => ''.$this->pluginName.''                         );                         /**add a filter to labels if you want to...**/                         $labels = apply_filters('wppizza_cpt_lbls', $labels);                                     $args = array(                             'labels'        => $labels,                             'description'   => sprintf( __( 'Holds %1$s  menu items data', $this->pluginLocale ), $this->pluginName ),                             'show_ui'       => true,                             'public'        => true,                             'menu_position' => 100,                             'menu_icon'     => defined('WPPIZZA_MENU_ICON') ? WPPIZZA_MENU_ICON : plugins_url( 'img/pizza_16.png', $this->pluginPath ),                             'has_archive'   => false,                             'hierarchical'  => false,                             'supports'      => array( 'title', 'editor', 'author','thumbnail','page-attributes','comments'),                             'taxonomies'    => array('') /* 'post_tag' for example*/                         );                         /**add a filter to arguments if you want to**/                         $args = apply_filters('wppizza_cpt_args', $args);                              register_post_type( $this->pluginSlug, $args );                     }                     /*******************************************************                         [register taxonomy + taxonomy related functions]                     ******************************************************/                     public function wppizza_register_custom_taxonomies(){                         $options = $this->pluginOptions;                              /**********************                             when using permalinks, we can either set the                             parent to be a dedicated page (admin->settings)                             .........                         ***********************/                         $sel_category_parent=get_post($options['plugin_data']['category_parent_page'],ARRAY_A);                         /**********************                         ........or use/set a default                         (required as other pages wont work without it when permalinked                         **********************/                         if($sel_category_parent['post_name']==''){                             $sel_category_parent['post_name']=$this->pluginSlugCategoryTaxonomy;                         }                                // Add new taxonomy, make it hierarchical (like categories)                           $labels = array(                             'name' => _x( 'WPPizza Categories', 'taxonomy general name' ),                             'singular_name' => _x( 'Category', 'taxonomy singular name' ),                             'search_items' =>  __( 'Search Categories' ),                             'all_items' => __( 'All Categories' ),                             'parent_item' => __( 'Parent Category' ),                             'parent_item_colon' => __( 'Parent Category:' ),                             'edit_item' => __( 'Edit Category' ),                             'update_item' => __( 'Update Category' ),                             'add_new_item' => __( 'Add New Category' ),                             'new_item_name' => __( 'New Category Name' ),                             'menu_name' => __( 'Categories' )                           );                           register_taxonomy($this->pluginSlugCategoryTaxonomy,array($this->pluginSlug), array(                             'hierarchical' => true,                             'labels' => $labels,                             'show_ui' => true,                             'show_admin_column' => true,                             'query_var' => true,                             'rewrite' => array( 'slug' => ''.$sel_category_parent['post_name'].'','hierarchical'=>true )                           ));                     }      which all works fine and in turn prints "WPPizza Categories" in the admin as title when editing/adding categories related to the wppizza cpt. So far so good. problem is as follows: when i go to a "normal category" (i.e http://www.domain.com/category/uncategorized/) the title tag looks like this (which is fine)                           <title>Uncategorized | sitetitle</title>      however, when i go to the custom post type/taxonomy like so http://www.domain.com/wppizza_menu/desserts/ (permalink) or just http://www.domain.com/?wppizza_menu=desserts , the title tag looks like this                           <title>Desserts | WPPizza Categories | sitetitle</title>      when - what i would like it to read is                               <title>Desserts | sitetitle</title>           in short, how do i get rid of "WPPizza Categories" in the title tag in the frontend ? hope the above makes sense. happy to provide more code if required of course


How to use WP-reCAPTCHA on a form

I have a Wordpress 3.5.1 powered website that has the plugin WP-reCAPTCHA installed. This plugin places a reCAPTCHA field at the bottom of the comments form of my website. For the life of me, I cannot figure out how to use this plugin on a template page that I've created, outside of the comments form. If I download the stand alone reCAPTCHA code, and try to use that, it throws fatal errors because the same library is already loaded, via the WP plugin. I'm hoping that someone will be able to help me out! Thanks, Ken


How to make Wordpress and TinyMCE accept <a> tags wrapping block-level elements as allowed in HTML5?

Starting with version 5 the HTML standard allows `<a>` tags wrap block-level elements. On a specific page I need to wrap a heading and an image with an `<a>` tag:               Some intro text.

Some heading

      While I can enter this in the text editor it causes some strange behavior: The code above will be transformed into this HTML code:
Some intro text.

Some heading

      Obviously, the opening `<a>` followed by a closing `</p>` for a never opened `<p>` is plain wrong. Also there's some non-closed `<p>` tag before the `<img>` tag. * * * Since this seems to be a newline-related issue, I tried to remove newlines from my Wordpress code:               Some intro text.

Some heading

      Interestingly, this results in the following HTML code:
Some intro text.

Some heading

      Now, there's still a closing `</p>` tag missing after the `<img>`. (Okay, HTML5 accepts non-closed `<p>` tags... but I don't think that this behavior is used intentionally here.) Also, Wordpress introduces a `<br />` that comes out of nowhere. So far to the Wordpress-related issues... * * * Now to the TinyMCE-related issues: When switching back from the text edit mode in Wordpress to the visual edit mode, the `<a>`s are still there. However, when switching back to text mode again (or saving the page from visual edit mode) the `<a>`s get completely removed. * * * Having this explained, let's come to my main question: **How can I make Wordpress and TinyMCE accept`<a>` tags wrapping block-level elements?** * * * Here's what I've already tried:   * Adding a filter to `tiny_mce_before_init` that sets TinyMCE's `valid_children` setting for `<a>`s to include `<h4>`s (as suggested in the question "HTML5, WordPress and Tiny MCE issue - wrapping anchor tag around div results in funky output")   * Adding a filter to `tiny_mce_before_init` that sets TinyMCE's `schema` setting to `html5`. I also found the ticket "Block `<a>` tags are getting stripped from the Editor", but don't really understand if stripping `<a>` tags is considered intentional behavior there.


post category in wp_insert_post

I'm building a wordpress theme where people can submit posts using wp_insert_post. The code below adds the post title but does not add the category specified by the user. Instead it puts it in uncategorized. How do I get it to add the user submitted category on submit?               <?php           if(isset($_POST['new_post']) == '1') {     $post_title = $_POST['post_title'];     $new_cat_ID = $_POST['category'];          //Checking if category already there     $cat_ID = get_cat_ID( $_POST['newcat'] );               //If not create new category     if($cat_ID == 0) {            $cat_name = array('cat_name' => $_POST['newcat']);            wp_insert_category($cat_name);     }          //Get ID of newly created category     $new_cat_ID = get_cat_ID($_POST['newcat']);               // Create post object     $new_post = array(     'ID' => '',     'post_title' => $post_title,     'post_status' => 'publish',     'post_author' => $user->ID,     'tax_input' => array( 'category' => $new_cat_ID )     );          // Insert the post into the database     $post_id = wp_insert_post($new_post);               // This will redirect you to the newly created post     $post = get_post($post_id);     wp_redirect( home_url() ); exit;     }          ?>      Heres the html form...                   <form style="" action="" method="post" id="foo">     <input type="hidden" name="new_post" value="1"/>     <input type="text" name="post_title" value="http://<?php echo $seal; ?>" id="input-title"/>     <input type="text" name="post_category" value="2" id="post_category" />     <input type="submit" value="Login">     </form>


Is there a way to make child posts inherit parent post terms?

I have a few custom posts that go from Parent to great grand children. I assign the parent post a term from a custom taxonomy that I would like for all of the child posts to inherit. Is there a way to do this? Or, could I make the child term pass up to the parent? Otherwise, I will have to apply the term to each post, which will be a very daunting task. Here is my structure:               -Staff Training, Student Curriculum, Resources, Training Plans (These are terms)     ---Tracks (CPT)     ------Topics (CPT)     ---------Courses (CPT)     ------------Resources (CPT)      As you can see, each resource has to be in a Course. Every Course has to be in a Topic. Every Topic has to be in a Track. And, every Track has a term from a custom taxonomy of Staff Training, Student Curriculum, Resources or Training Plan. Now, Training Plan is different in the fact that it will contain mostly just Resources that are put together and are already associated with another term. So, this means that some Resources will have more than one term. However, Tracks, Topics and Courses will only have one term. I imagine that I will have to get all of the children of the parent CPT and apply the term that way. Or, maybe I apply it to the Resource and allow it to propagate upwards through the parents? Any help you can afford would be great!


Wordpress dashboard + website are totally messed up

I just shifted my website from local host to server. Everything is messed up in the website and the dashboard. It is just a text in a white background. ![enter image description here](http://i.stack.imgur.com/9DppT.png) ![enter image description here](http://i.stack.imgur.com/7hHD4.png)


Get uploaded image url

I am working on a plugin that constructs a newsletter witch uses a template with a few images. The images have been uploaded using the Media Library (`uploads/current_year/current_month/`) and I want to get the images URL by using the image name. Any way of doing this without iterating over all the images? I have tried to store the images in the plugin folder but the website uses https and this location is not accessible without authentication. Any suggestions on different location for storing the images?


Hide the word 'category' from my permalinks

How can I hide the word 'category' from my permalinks? ![image showing category in permalink](http://i.stack.imgur.com/JL6Cr.png) Regards.


How to add a help tab to all admin pages - including plugin pages

I have working code which adds a help tab to all screens in the admin which already have help options or a help screen - however, screens which don't have contextual help - such as the plugin I writing, also don't recognize the add_action call - how can I ensure that the help_tab appears on each and every screen in the admin? Some simple code - but it's more or less exactly like in the Codex. I add the action in the class __construct               // add help tab to admin UI ##     add_action( "load-{$GLOBALS['pagenow']}", array( $this, 'add_help_tab' ), 20 );      This calls a method in the class "add_help_tab":               public function add_help_tab() {             foreach ( $this->help_tabs as $id => $data ) {                 get_current_screen()->add_help_tab(                      array(                         'id'       => $id                        ,'title'    => __( $data['title'], 'q_support' )                        // Use the content only if you want to add something                        // static on every help tab. Example: Another title inside the tab                        ,'callback' => array( $this, 'callback_function' )                     )                  );             }     }      Which in turn calls the callback method "callback_function" - this all works as expected, except on screens without pre-existing help tabs - is there a way I can ensure each and every page includes the help tab feature?


How to add qtranslate multi language support for media?

The multi language plugin qtranslate works for custom post types but there is no capability to translate media information like title, description, captions for images. I am using the following code (WP v3.7.1) in order to adding support for custom taxonomies translation:               add_action('admin_init', 'qtranslate_edit_taxonomies');          function qtranslate_edit_taxonomies(){        $args=array(           'public' => true ,           '_builtin' => false        );        $output = 'object'; // or objects        $operator = 'and'; // 'and' or 'or'        $taxonomies = get_taxonomies($args,$output,$operator);        if  ($taxonomies) {          foreach ($taxonomies  as $taxonomy ) {              add_action( $taxonomy->name.'_add_form', 'qtrans_modifyTermFormFor');              add_action( $taxonomy->name.'_edit_form', 'qtrans_modifyTermFormFor');                       }        }          }      I think qtrans_modifyTermFormFor can be used for any input box but I don't know which hook to use. I checked media.php but no luck. Is there anything that can be done like the example above for the attachment details inputs?


Displaying the full text instead of post title

I've installed recently WordPress (I guess it should be 3.0? cannot find easily the version number) and my first post appears only the title (linked) and to see the full text one must click the title. Is there a setting for displaying the full text of a post instead of the title?


Creating "static" taxonomies to choose from, inside custom post type?

Alright, so i have a custom post type called Blurbs (translated, sort of). I want to add a static set of categories for the posts within Blurbs (i don't want the user to be able to create custom categories). I want two different types of categories; links and page-excerpts. I did some reading and came to the conclusion that taxonomies is the way to go for adding these "categories" to the post type. I got as far as creating the taxonomy, but i don't want it visible in the menu. I just want the "category"-box on the edit/publish screen, with the two static items. This is what i have so far:                     $labels = array(             'name' => 'Categories',             'singular_name' => 'Category',             'search_items' =>  'Search categories',             'all_items' => 'All categories',             'edit_item' => 'Change category',              'update_item' => 'Update category',             'add_new_item' => 'Create new category',             'new_item_name' => 'New category name'           );                    register_taxonomy('categories', array('blurb'), array(             'hierarchical' => true,             'labels' => $labels,             'show_ui' => true,           ));      By setting the show_ui to false, it disappears from both places (menu and links-box). So, the two questions i need help with is: 1) How do i remove it from the menu? 2) How do i give it "static" options (aka categories) to choose from?


Wordpress/Server outputting strange result

I've got a custom wordpress site that locally is working fine. However on the staging server, on random occasions it outputs just the html, partially incomplete. The output always seems to be missing a portion of the top part of the html, but with a random on the second line, and a 0 at the end of the page. ![This is an image of what is outputted](http://i.stack.imgur.com/6OMeD.png) I'm thinking this is a buffer issue. Has anyone had this issue or could shed some light on it? -- Edit This general happens most when accessing the backend pages. I'm certain it must be some server related setting that is causing this. Maybe buffer size?


How to control size of comments popup window?

Is it possible to control the size of the window that is opened with `comments_popup_link()`?


Should I use a multisite installation to achieve a multi-language site?

This is partly a follow up to my earlier question: How can I make a site viewable in multiple languages?. It turns out the client wants to have the content manually translated, rather than using something like Google's translation tools. With that in mind, my first thought is to use a multisite installation with subdirectories, i.e. site.com/en/, /fr, /cn, etc. Is this the most logical way to achieve the desired result. Keep in mind only the content needs to be in multiple languages, not the admin interface.


WordPress 3.0.1 on IIS 6 Web Server PermaLink Issues

I recently stumbled upon this blog on " Using IIRF URL Rewriting on IIS6 with WordPress" ( http://john-sheehan.com/blog/using-iirf-url-rewriting-on- iis6-with-wordpress/ ) by John Sheehan as I installed a WordPress site I developed on my Mac OS X running MAMP and then ported the site to a MS IIS6 Windows 2003 Server environment. Going to the home page all works fine but then all my other pages could not be found - 404. My site is setup with PermaLinks in WordPress 3.0.1 where I am using the Custom Structure /http:/www.mysite.com/%postname%/ So an example permalink for one of my pages that cannot be found is http://www.mysite.com/aboutus Reading up on this, I am assuming the reason my pages cannot be found is because of my .htaccess file not being compatible on IIS 6 server as this is an Apache only file. Anyways, to cut a long story short, looking at the site/blog entry above, regarding the use of IIRF URL Rewrite and me being a complete newb to rewriting URLs, I have the following queries: A) To achieve my Permalink Custom Structure of /http:/www.mysite.com/%postname%/ what would my Rule's File look like, so that WordPress on IIS 6 will actually find my pages described above? B) What is the name of this file and where (location) on the Web Server do I place the Rule file? C) Do I need to remove my current .htaccess file within my WordPress directory that holds my site on IIS 6? Any help on this would be much appreciated. Thanks.


Display Images with More Fields yes / no

I am creating a site and installed the More Fields plugin option to create custom fields in the posts. I'll have an area for downloads, which will provide Word and Excel files to download. If I create a field of type yes / no, as I call the code so that "If you marked YES" shows the image, and if you have marked as NO, hides the image. Can anyone help me? thank you


How to override Member's Avatars in BuddyPress

I have tried everything to override the BP Avatar. Found about 5-6 different Google results that basically all point to the same solution:               function override_bp_member_avatar($url) {         return get_stylesheet_directory_uri() . '/default_avatar.png';     }     add_filter('bp_core_fetch_avatar_no_grav', '__return_true'); // http://codex.buddypress.org/extending-buddypress/tips-tricks/     add_filter('bp_core_mysteryman_src', 'override_bp_member_avatar'); // http://www.buddyboss.com/instructions/      Yet it does not work. Has anyone had success using a default Avatar for members?


Only Display Comments From Comments URL

I'm trying to clean up my blog by only displaying comments when a user specifically wants to - as in they click on the "view comments" URL. I've formatting my posts normally, and at the end I have a link to display comments, using the comments_link() function. The comments_link() function seems to take the post and append a "/#comments" to the posts permalink URL. What I would like to do is analyze the URL to see if the "/#comments" is in the URL, and if so then I would call my custom action to display the comments, otherwise I will post a comments_link asking the user if he wants to post the comment. If there is any other flag built into WP for determining whether the user clicked on the comments link, that would be preferable as well. The only problem is, I'm not sure how to analyze the URL to determine if they clicked on the comments link. Any help is appreciated, thanks.


LaTeX formulas in title of the post?

Is there anyway that one can put a LaTeX formula on the title of a post? I know that they eventually become an image, while being used inside posts, but I'm just curious.


How can I send a welcome email to a user AFTER they login for the first time?

What I want to do is after a user creates an account... they log in for the first time it will kick off a welcome email to the user that will give them an overview of the site and suggestions of what they should do to get the most out of the site. I'm not sure where this would go... any help would be great.


Multiple Authors on a Single Blog

I'm currently researching into using WordPress and so, apologies in advance if this seems like a very basic question. Our main requirement is to have a single blog, but allow multiple users / authors (essentially the entire organization which could be up to 100 people) to post. Is this possible in WordPress? We would be hosting WordPress within our organization (e.g. in an intranet environment). Thank you!


How to enlarge the media file upload size in wordpress admin

I'm using wordpress 3.0 with buddypress. I need to enlarge the file size that is being uploaded from the media section in the admin menu. We have tried many ways including the methods from this link but nothing made it larger than a 1 mega. Is there a different way to do it?   Thanks


Put folder in theme via plugin

I've created a set of customisations for WordPress and turned these into a very simple plugin. As part of this customisation process I also need to manually ftp a folder containing css and some images, to the theme folder. Is it possible to package this folder with my plugin and have the plugin move the folder over to the required location(s)? If so, any pointers would be greatly appreciated.


Getting only the most recent bookmark?

So, I was thinking I'd use WordPress' Bookmarks/Links content type to populate a slider... ...Except there are a grand total of four functions interacting with this part of WordPress. I don't think you can even access these with a WP_Query object, and it seems all date-related data attached to these is in relation to the last update of the link itself (I.e., when the linked-to page is updated). **Is there any way to even retrieve only the most recently-added bookmark?** (For more of a semi-related discussion question for the comments -- if this aspect of WP is so woefully underdeveloped 3 versions of the CMS in, why not just farm out this functionality to a plugin? Simply backwards compatibility?)


Manipulate retrieved ajax data in php

I made a basic ajax request to 2 variables. I want the values to be sent and manipulated in the back-end in order to use them in a database query. All that should happen on page load. My main.js code: main.js file               var lat =  21.458965;     var lng =  -11.336985;     jQuery.ajax({             type:"POST",               url: ajaxurl,                                data: {'action':'func',                    'lat':lat,                    'lng':lng},              success:function(data){                     // note that i don't want the data to return back to the front-end.                                  },                             error:function(errorThrown){                                 console.log(errorThrown);                             }                         });             }      functions.php               wp_register_script( 'main', plugin_dir_url( __FILE__ ).'js/main.js', array( 'jquery' ) );     wp_enqueue_script( 'main' );          function func(){         if(isset($_REQUEST)){                 //i tried to retrieve using $_POST and $_GET but the 2 arrays where empty.                 // i need to retrieve  both vars and take them out of the function then use them in a db query.              }     }     add_action('wp_ajax_func', 'func');     add_action('wp_ajax_nopriv_func', 'func');      What i wanted here is to send data (2 int variables to be specific) from javascript file to functions.php so any other way to do that please tell me about it. To do that i created a form with 2 hidden input elements using JS then submit it with $('form').submit(); but the page was loading twice(the normal page load and the submit reload).


Add comment feature to woocommerce Shop page

I want users to give their Reviews about the products. Currently have woocommerce installed in my wordpress site . I want to add the comments at the bottom of the Woocommerce shop page (not single product page), below last product in the shop page. I have tried using wp_list_comments( ); But all it is not showing comments. Thanks for your help in advance.


Setting page title and keywords from PHP code

does WP offer any functions which can be used to set the page title and/or keywords from the PHP/Controller level? I'm basically looking for something like the wp_enqueue_style() function, which results in changes to the HTML page header but for the title and keywords fields. I have some PHP code which dynamically retrieves/builds the page title and would like to avoid having to alter my theme/templates to display this. Greetings/Thanks Robert


Limit number of emails per second

Our users have been complaining about activation emails taking a while to be received. After digging around, we discovered that about 50% of users get the emails instantly and the other 50% take between 5 mins and 2 hours, which is unacceptable. We determined that Wordpress was sending emails at a rate of ~20+ emails/sec and Godaddy's threshold is 4 emails/sec, which I think is causing this problem. Is there a way for me to limit stagger the emails out a bit more? Are there plugins or settings I can adjust to resolve this?


Get image path : image is upload but not attached

my first question is ... I want to retrieve path of an upload image. Important: The image isn't atached of any post. I have image url like: `http://localhost/wp-content/uploads/2011/06/sample.jpg` And I want to get the path, like: `/Applications/XAMPP/htdocs/wp-content/uploads/2011/06/sample.jpg` Thanks, Marcos. *I'm trying to improve my English. Sorry.


Redirect all posts urls from without .html to .html

How can i redirect all posts permalinks to .html ,in Wordpress ? now all my posts url are ending in .html ,but before it was without .html to be more clear ,for example a post url like this www.example.com/posturl to be redirected to www.example.com/posturl.html .it's simple to redirect them one by one,but i need a rule to redirect all posts . Thank you


Pros and Cons for high "expire time" on wp-super-cache or w3-total-cache?

In the wp-super-cache page, there is the following sentence, which I do not understand:: > Checking for and deleting expired files is expensive, but it’s expensive > leaving them there too. On a very busy site you should set the expiry time > to 300 seconds. Let's say that I am using a low expiry time, doesn't that mean that the cache needs to rebuild over and over every 300 seconds? I mean, most of my content (except for the home page), does not change. So why should I matter if most of the posts will simply stay the same for days?


Plugin for automatic database backup?

Is there a reliable plugin that I could use to automatically backup the WP database? **It's really important that it's just the database and not the files.** I'd like it to automatically download a copy of the database and store it on my computer in a specified file. Is there one out there that could do this?


wp_get_post_terms Order by not working

wp_get_post_terms Order by not working My code is here               query_posts(array('post_type' => 'product','post__in' => $product_ids,));          while (have_posts()) : the_post();         global $post;          $args = array('orderby' => 'name', 'order' => 'ASC', 'fields' => 'all');     $product_terms = wp_get_object_terms($post->ID, 'productcategory',$args);     if(!empty($product_terms)){       if(!is_wp_error( $product_terms )){         echo '
';         foreach($product_terms as $term){           echo '
slug, 'product').'">'.$term->name.'
';          }         echo '
';       }     }          endwhile;      I read read on the documentation that its support array $args to make order the terms by "name", ASC however I don't know why it wont work


Menu highlight custom post type archive

I am a WP beginner and hope if anyone can help me out. I have recently installed **WP 3.3.2** and **Jigoshop 1.2** to see how things works if I can use WP as an ecommerce website. The problem I am facing at the moment is in order to display the products, Jigoshop creates a page in WP, as when you click on the page the link will get redirect from `?page_id=5` to `?post_type=product`. As the page being redirected the current_page_item class doesn't stay/appear to show the style for current position in the menu. The current menu code is `<?php wp_nav_menu( array( 'container_class' => 'menu-header', 'theme_location' => 'primary' ) ); ?>` Many thanks for the help in advance.


Creating a gallery custom post type?

Hi I was wondering if it is possible to create a custom post type called "Gallery" where i only upload photos and ad captions and when i post it, it post as a gallery. Also when it shows on the homepage it shows as "View Photos" instead of read more, and goes straight to the gallery page. Also i want to be able to add taxonomies such as "Tv Show" so it will be like this mysite.com/photos/tv-show-name/photo-gallery The post below didn't help me, i tried that plugin and it didn't work for me it didn't go to a gallery it went to a single post page with nothing on it. Creating Photo Gallery System with Custom Post Type


What is the best way to change sidebars based on custom taxonomy terms?

I would like to load different right and left sidebars depending on a custom taxonomy term. If there is no term from this custom taxonomy, then just load the default sidebar.php and sidebar-right.php files. For example, the alternate sidebars would be something like:   * sidebar-carrots.php and sidebar-carrots-right.php   * sidebar-apples.php and sidebar-apples-right.php   * etc. I know about the Widget Logic plugin, but I want more control and need to load completely different sidebar template files. I'm sure that I could throw together something messy and functional, but I would like to know what is the best way to set that up.


Hide tag and category boxes from the post editor

I want to hide the tag and category boxes from the post editor, the theme I've just developed doesn't need them, thus I want to hide them. I am aware they could be hidden using the 'screen options' menu, however I'd prefer to do this with a bit of code. Is this possible?


Broken theme, template is missing

I'm beginning to learn theme creation, so I have created a very simple theme :               my_theme         css             style.css         images             logo.png         index.php      But in wordpress, it appears as a broken theme : "missing template". Why ? style.css :               /*     Theme Name: Kaoka     Description: Theme personnalise pour le site Kaoka     Version: 0.1     Author: Agence Nature / Brunet Production     */     * {         border:0px;     }      index.php :               <!DOCTYPE html>                     <meta charset="utf-8">         <title>Mon premier tutoriel</title>         <link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css">
Bienvenue sur le site <?php bloginfo('name'); ?>

<?php bloginfo('description'); ?>
                  Thanks


Redirect after closing Theme Customizer when user does not have permission for theme page

I'm looking for a way to alter the href target for the "close" button from the theme customizer. Another question/answer came very close, but in my case the solution used which involved "load-themes.php" doesn't work because the user in question wouldn't have permission to access that page. ( Wordpress Customizer: custom redirection after closing ) Basically the "Close" button now takes the user to a page that tells them they don't have permission to access it. I'd like it to redirect to the main admin page but I'm not sure how to do that. The other solution mentioned using jQuery, but I have NO clue how to do that. I tried messing around with it for a while but I really have no idea what I'm doing at this point. Any help would be greatly appreciated!


Theme My Login %username% in permalink

I wonder how i can set username as a variable in the permalink! i have a own page for each of my users. I want to add a "common" link in Custom link setting with the name "My Page" and the URL like www.mydomain.no/user/10558962678 My pages is set up with username in the url. Pls Can someone help me? http://wordpress.org/extend/plugins/theme-my-login/


Sort custom posts in archive by multiple values: date AND meta key

I have a post type and I want to sort posts in its archive according to two values:   1. by a **meta** value called "artwork_year" which contains a 4 digit number (year)   2. by post **publish date** _what the query should do is:_ first get the artwork_year and sort the posts accordingly (show first higher number... ie first 2012 artwork, then 2011, then 2010, etc), then since many posts share the same year, sort them by publish date. I followed instructions at http://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters then tried with                   $artwork = array(                     'post_type' => 'artwork',                   'posts_per_page' => 10,                'paged' => get_query_var( 'paged' ),                'meta_key' => 'artwork_year',                 'orderby' => 'meta_value_num date',                 'order' => 'DESC'              );              query_posts( $artwork );               while ( have_posts() ) : the_post();                      // loop stuff              endwhile;              wp_pagenavi();      however, if I do this... the order is not right... now I set it to DESC which is the default; it should display first artwork from 2012, then 2011... and sort the artwork with the meta value 2011 or 2012 according to pub date... however what I get is first 2011 artwork in any case (regardless of if order is set to ASC or DESC) then 2012 posts... how do I get 2012 first and then 2011 and all others? thank you!


magic "MENU" button under Twenty Twelve theme

I'm using Twenty Twelve with one of my sites on WordPress and someone told me that the site wasn't appearing as it should. She told me that instead of the menu, she saw a "MENU" button, which if clicked, gives a long list of all the pages. After some investigating I found that if a browser is resized very small, or when viewing on mobile browsers, the menu is replaced by this button. I'm not sure how big her browser window was, but seeing as she was viewing it on a PC I'd not have thought it was that small. The funny part is, even when You are on iPhone5 with full HD resolution You still get the MENU button. My question though, is it possible to disable this feature? It's highly annoying, it really needs to be optional. Having to click 'menu' to get a list of pages just isn't user friendly.


How to replace the_post_thumbnail template tag and show the first inside the post image instead

I want WordPress to return the first post image or a default image if no featured image has been set. My theme uses `the_post_thumbnail` many times, so I don't want to go through and change all references to a new function. I'd rather filter the core. Here's what I've added to `functions.php`:               add_filter('post_thumbnail_html', 'my_thumbnail_html', 10, 5);          function my_thumbnail_html( $html, $post_id, $post_thumbnail_id, $size, $attr ) {         global $post, $posts;         if (has_post_thumbnail() ) {             echo get_the_post_thumbnail( null, $size, $attr );         }         else {             $first_img = '';             ob_start();             ob_end_clean();             $output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches);             $first_img = $matches [1] [0];             if(empty($first_img)){                 $first_img = get_bloginfo("template_url") . '/images/default.gif';             }             return $first_img;         }     }      How do I hook this correctly?


Getting the Featured image URL and inserting it as Custom Field on Post update / publish

I've tried a number of solutions posted here regarding converting custom fields to featured images - of course in reverse; but non seem to work for me. What I'm trying to do is grab the Featured Image URL once the image is uploaded and set as a featured image; then automatically set the full size image URL as a custom field. This needs to work on both post Update for existing articles that do not currently have the custom field set and for post Publish for new articles. As mentioned I have tried numerous suggestions based on this but none seem to work. Here is the last bit of code that I attempted without success though - and the frustrating part is that I cannot seem to debug or get any errors out of this:               add_action('publish_page', 'add_custom_field_automatically');     add_action('publish_post', 'add_custom_field_automatically');     function add_custom_field_automatically($post_ID) {     global $wpdb;         $post_thumbnail_id = get_post_thumbnail_id();         $post_thumbnail_url = wp_get_attachment_url($post_thumbnail_id);         add_post_meta($post_ID, 'lead_image', $post_thumbnail_url, false);     }


Fancybox not working. why?

Ok, I tried to implement a fancybox lightbox in my custom theme. I enqueued my scripts in functions.php:               function ikos_add_lightbox() {     wp_enqueue_script( 'fancybox', get_template_directory_uri() . '/inc/lightbox/js/jquery.fancybox.pack.js', array( 'jquery' ), false, true );     wp_enqueue_script( 'lightbox', get_template_directory_uri() . '/inc/lightbox/js/lightbox.js', array( 'fancybox' ), false, true );     wp_enqueue_style( 'lightbox-style', get_template_directory_uri() . '/inc/lightbox/css/jquery.fancybox.css' );     }     add_action( 'wp_enqueue_scripts', 'ikos_add_lightbox' );      In my js for the lightbox:               (function($) {          // Initialize the Lightbox for any links with the 'fancybox' class     $(".fancybox").fancybox();          // Initialize the Lightbox automatically for any links to images with extensions .jpg, .jpeg, .png or .gif     $("a[href$='.jpg'], a[href$='.png'], a[href$='.jpeg'], a[href$='.gif']").fancybox();          // Initialize the Lightbox and add rel="gallery" to all gallery images when the gallery is set up using [gallery link="file"] so that a Lightbox Gallery exists     $(".gallery a[href$='.jpg'], .gallery a[href$='.png'], .gallery a[href$='.jpeg'], .gallery a[href$='.gif']").attr('rel','gallery').fancybox();          // Initalize the Lightbox for any links with the 'video' class and provide improved video embed support     $(".video").fancybox({         maxWidth        : 800,         maxHeight       : 600,         fitToView       : false,         width           : '70%',         height          : '70%',         autoSize        : false,         closeClick      : false,         openEffect      : 'none',         closeEffect     : 'none'     });          })(jQuery);      So this is supposed to work like commented in the js... My code for the gallery trying to use the lightbox right now:               <?php         if ( $attachments = get_children( array(         'post_type' => 'attachment',         'post_mime_type'=>'image',   //return all image attachment only         'numberposts' => -1,   //get all the attachments         'post_parent' => $post->ID     )));          foreach ($attachments as $attachment) {          $src = wp_get_attachment_image_src( $attachment->ID, full);          $html = '';     $html .= wp_get_attachment_image( $attachment->ID, 'gallery-thumb') .'';     echo $html;     }     ?>      It is supposed to work with any .jpg, .gif or .png but didn't because my images are all .jpg. So I added the class .fancybox to the link and nothing... So I even tried to add the gallery rel but nothing happens... Console log shows no errors :/ Any help is highly appreciated!


Is there a plugin to insert pre-defined link into editor?

After searching several hours, I've decided to crowd-source this one. I have a client who uses Wordpress very frequently, they often have to create a link to a certain page for collecting donations - the issue is they always get the link wrong (long story, but they always screw it up!). I've been searching for a plugin or tutorial on how I can add a button to the editor that would automatically add the link to their post - ensuring the link is always correct. As mentioned I searched several hours and was wondering if someone could point me in the right direction. Thanks!


Loop problem - Taxonomy

I think that I have a problem with the loop on my taxonomy page. On any part of the code (specially on the sidebar) that I need the permalink, it always return the link of the first item of the taxonomy loop, but the correct, is of the current page. This is my taxonomy page code:               <?php get_header(); ?>

             <?php $term_global = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy')); ?>
<a title="Voltar" href="<?php echo get_bloginfo('url') . '/colecoes'; ?>">< Voltar

<?php echo $term_global->name; ?>

             <?php if (have_posts()){ ?>                 <?php while (have_posts()){ ?>                     <?php the_post(); ?>                 <?php } ?>             <?php } ?>             <?php rewind_posts(); ?>             <?php wp_reset_query(); ?>             <?php get_sidebar('colecoes'); ?>             <?php wp_reset_query(); ?>

             <?php                 $args = array('post_type' => 'colecoes',  'paged' => $paged, 'posts_per_page' => 12, 'order' => 'DESC', 'taxonomy' => 'categorias', 'term' => $term_global->slug);                 $loop = new WP_Query($args);                 $contagem = 0;                 if (sizeof($loop->posts) >= 1){                 echo "
";                     while ($loop->have_posts()){                               $loop->the_post();                         $args = array(                             'post_type' => 'attachment',                             'numberposts' => null,                             'post_status' => null,                             'post_parent' => $post->ID,                             'numberposts' => 1                         );                         $attachments = get_posts($args);                         if ($contagem == 2 || $contagem == 5 || $contagem == 8 || $contagem == 11 || $contagem == 14){                             echo "
";                         }else{                             echo "
";                         }                         if ($attachments) {                             echo 'post->post_name . '" title="' . get_the_title() . '">';                                 echo '
';                                     the_thumb(get_the_title(),0,1,false);                                     the_thumb(get_the_title(),1,2,false);                                 echo '
';                             echo '';                         }                         echo '
';                             echo '
post->post_name . '" title="' . get_the_title() . '">'.get_the_title().'
';                         echo '
';                         echo "
";                         if ($contagem == 2 || $contagem == 5 || $contagem == 8){                             echo '

';                         }                              $contagem = $contagem + 1;                     }                     echo "
";                 }else{                     echo category_description();                  }             ?>

                 <?php wp_pagenavi(array('query' => $loop)); ?>                 <?php rewind_posts(); ?>                 <?php wp_reset_query(); ?>

     <?php get_footer(); ?>


Display thumbnails for certain category posts

I have wondered about the web and came across this beautiful piece of code:               if(has_post_thumbnail()){           the_post_thumbnail();            }else{             echo '<img src="' .  get_bloginfo('template_directory') . '/images/default_post_thumb.jpg" />';          }      What it does, is adds a default thumbnail to every single post. That's good for a portfolio blog, but what if I have loads of categories, e.g. one category is tutorials and another is music - I must have different default thumbnails for those categories. Can anybody please explain to me how I can customize this code to show different _default_ thumbnails for different categories? Thanks :)


Adding another "Add Post" button to admin

I would like another "Add post" button in the admin except I am going to call it "Add voucher". It will run specific plugins that add post will not. However that is irrelivant, all I need to know it how to add another add post button with the same features.


How to handle high load of traffic of my server

Soon, my website will have much traffic due to an event, is there anyway or any service that will help me to handle all the traffic without my website goes down? I'm using WordPress running on Nginx with W3 Total Cache 0.9.2.11 and cloudflare.


SQL query to select posts from multiple categories

I have built a query to select posts within a category. Works fine. But when I choose to add a secondary filter to exclude a category, the query return the same result set, as if the secondary category filter is being ignored. In the following the query should select all posts in category 7 and exclude those in category 10:               $querystr = "SELECT * FROM $wpdb->posts      LEFT JOIN $wpdb->term_relationships ON($wpdb->posts.ID = $wpdb->term_relationships.object_id)       LEFT JOIN $wpdb->term_taxonomy ON($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id)            WHERE ($wpdb->term_taxonomy.term_id = 7        AND $wpdb->term_taxonomy.term_id <> 10          AND $wpdb->term_taxonomy.taxonomy = 'category'           AND $wpdb->posts.post_type = 'post'          AND $wpdb->posts.post_status = 'publish')";      Can someone help?


Searching With Apostrophe

I'm having trouble with my custom theme's search function. I have a number of posts with apostrophes in the title. For example, `McDonald's`. However, when I try searching say `McDonalds`, the post won't return in the search results. How can I go about making sure that `McDonald's` would return in the result even if the user didn't include the apostrophe.


how to get wordpress user id when user register

im creating wordpress user using `wp_create_user()` function and when user creating i want to add that users userid to custom table, this is the way i tried               add_action( 'user_register', 'atuser_info');     function atuser_info( $user_id ) {                   global $wpdb;          //$prefix=$wpdb->prefix;                         $query_userinfo = "INSERT INTO user_info (id,fname,lname,address_1) VALUES      (".$user_id.",".$_POST['fname'].",".$_POST['lname'].",".$_POST['address_1_step2'].")";         $wpdb->query($query_userinfo);     }


How to conditionally hide author name on Single.php if category is "news", otherwise if category is something else display author name?

I would like to be able to conditionally hide the author's name on the Single.php if the Category name is equal to "News" and otherwise if the category is something else hide it. How do I go about doing this? The code I have below does not seem to work:                                        <?php get_header(); ?>
                               <?php include('includes/top-pagination.php'); ?>

                                               <?php if (have_posts()) while (have_posts()) : the_post(); ?>

<?php the_title(); ?>
                                                                                <?php if(is_category('news')) { ?>
<?php echo get_the_date('m.d.Y'); ?>
                         <?php  } else { ?>
By <?php echo get_the_author(); ?> / <?php echo get_the_date('m.d.Y'); ?>
                         <?php } ?>                                                                                <?php the_content(); ?>                                                       <?php //endif; ?>

                                                                                <?php include('includes/social.php'); ?>                                                                                <?php //comments_template( '', true ); ?>                                                       <?php endwhile; ?>

                     <?php include('includes/whats-happening.inc.php'); ?>

                                            <?php get_sidebar(); ?>                                            <?php get_footer(); ?>


how to get last revision id created after wp_update_post

wordpress always store revision after call wp_update_post. How to get the post revision ID after call wp_update_post? Thanks


How can I display a drop-down select of Post Names

I would like to add a custom write panel to a custom post type. I'm looking at the the code here: http://wefunction.com/2009/10/revisited-creating-custom-write-panels-in- wordpress/ I can get the custom write panel to appear on a standard post edit page but not for my registered custom post type.               add_meta_box( 'int_parent_meta', ucfirst( $key ) . 'Options',         'display_meta_box', 'name-of-custom-post-type', 'normal', 'high' );      If I replace 'name-of-custom-post-type' with 'post' in the above line, the panel appears on the post edit screen. Anyone know what I'm missing here? Wordpress version is 3.0.1


Cache plugin Cache all Pages by cron

Does someone know if there is a cache plugin where you can choose if you can cache all pages at once? And if possible with a cron!


When is it a good idea to build a permalink structure from scratch?

Is it a good idea to design a permalink structure from scratch? The requirements to the structure are as follows:   * Pages to be referenced by their structure (`example.com/grandparent-slug/parent-slug/child-slug`).   * Posts to be referenced by category and date (`example.com/category-slug/2013/07/my-post-slug`).   * Archives only available by category (`example.com/category-slug`), by category and year (`example.com/category-slug/2013`) by category, year and month (`example.com/category-slug/2013/07`) and by tag (`example.com/tags/tag-slug`).   * All other links, like comments, feeds, trackbacks, pagination, archive by author and day, attachments are to be disabled. Is it a better idea to create a new structure following these requirements or to modify an existing structure? In case of a new structure, how does one go about the permalink setting in WP admin? They are site-specific, and the theme needs to override them.


Wordpress include scripts and style in plugin page

I am working on a Wordpress plugin where I want to include some jquery scripts and stylesheet. I found dit piece of code in an article and this should do the job, but it doesn't work for me. Can someone tell me what I am doing wrong?               // Include files     function my_scripts() {         wp_enqueue_script( 'jquery' );         wp_register_style( 'filename.css', plugins_url('filename.css', __FILE__) );         wp_enqueue_style( 'filename.css' );     }          add_action('wp_enqueue_scripts','my_scripts');


Edit Image/Image Details - Replace button missing

I have a strange problem. I am dynamically populating content into Wordpress' tinyMCE editor. Part of this content is a placeholder image, that the user can then replace. The issue is when I click the 'pencil' icon to edit, I am not given the "Replace" button like I would any other images. This is what I see: http://imgur.com/Bjoencj This is what I expect, and works on images imported from the media library: http://imgur.com/fra3PfX **Notice, the replace button is present in the second example. I guess because the image is hard-linked and wordpress has no way of knowing if the image exists in the media library. How can I dynamically import an image so this functionality is present?**


Display custom field & value correctly on page

I have products with a list of custom field values which are loaded via CSV, but not all products have a value for every custom field as the field is not relevant to that product. I want to be able to call up every relevant custom field name and its value on the page for each product. I am using this which does display the custom field value (only) on the page:               <?php echo get_post_meta( get_the_ID(), 'current_promotions', true ); ?>      However I would like to display the field name and value for each product where appropriate. Can anyone help?


Can I Remove xmlrpc.php completely?

My site is getting a lot of malicious traffic to domain.com/xmlrpc.php, to the point that the server is not being able to handle it. I tried to disable it via the wp-config.php, by adding this line:               add_filter('xmlrpc_enabled', '__return_false');      And I also tried this plugin, but neither method seemed to have worked. Now I am considering to completely remove the php file, but I would like to be sure I won't destroy other things. Does anyone know if it's safe to remove that file?


date/time-picker and file upload (image) fields for custom fields (e.g. with more fields)

I got used working with the More Fields plugin. But it seems that fields like   * datepicker   * timepicker   * date/timepicker   * image upload (media library) are missing somehow. Is there a plugin which can do that? I already found Advanced Custom Fields together with the Date and Time Picker Field Addon or Simple Fields. But both seems to have issues with the latest versions. More Fields has a file upload feature but it should be possible to upload images in the media library to prevent duplicate content. The last option which comes to my mind is using the WYSIWYG editor together with text input fields (for date and time, for picture URL from media library). Are there some easier solutions for the editor?


Archive Page for Custom Post Type is not Working

I have registered a custom post type "tutorials" with the following snippet.               <?php     /*     Template Name: Tutorial Archive     */     get_header(); ?>

     <?php             $temp = $wp_query;             $wp_query = null;             $wp_query = new WP_Query();             $wp_query->query('showposts=8&post_type=tutorials'.'&paged='.$paged);             if ($wp_query->have_posts()) :     ?>
Tutorials Archive
     <?php while ($wp_query->have_posts()) : $wp_query->the_post(); ?>     <article class="posts" id="post-<?php the_ID(); ?>">
<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?>

by Admin

<?php the_time('F jS, Y') ?>

<?php echo get_post_views(get_the_ID()); ?>

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

<?php $excerpt = get_the_excerpt(); echo archive_excerpt($excerpt,40); ?> →

     <?php endwhile; ?>     <?php if( function_exists('numeric_pagination')) { numeric_pagination(); } else { ?>

<?php next_posts_link('« Older Entries') ?>

<?php previous_posts_link('Newer Entries »') ?>

<?php } ?>            <?php $wp_query = null; $wp_query = $temp; // reset     ?>     <?php else : ?>

Not Found!

Sorry, but you are looking for something that isn't here.
     <?php endif; ?>

     <?php get_sidebar(); ?>     <?php get_footer(); ?>     ----------- this is imy functions.php file -------------     <?php      // numeric_pagination function on functions.php     function numeric_pagination() {             if( is_singular() )                     return;                     global $wp_query;             if( $wp_query->max_num_pages <= 1 )                     return;                     $paged = get_query_var( 'paged' ) ? absint( get_query_var( 'paged' ) ) : 1;                     $max   = intval( $wp_query->max_num_pages );                             if ( $paged >= 1 )                                     $links[] = $paged;                             if ( $paged >= 3 ) {                                     $links[] = $paged - 1;                                     $links[] = $paged - 2; }                             if ( ( $paged   2 ) <= $max ) {                                     $links[] = $paged   2;                                     $links[] = $paged   1;  }                     echo '

' . "\n";                             if ( get_previous_posts_link() )                                     printf( '
%s
' . "\n", get_previous_posts_link() );                             if ( ! in_array( 1, $links ) ) {                                     $class = 1 == $paged ? ' class="active"' : '';                                     printf( '
%s
' . "\n", $class, esc_url( get_pagenum_link( 1 ) ), '1' );                             if ( ! in_array( 2, $links ) )                                     echo '
%u2026
';    }                                     sort( $links );                                     foreach ( (array) $links as $link ) { $class = $paged == $link ? ' class="active"' : '';                                     printf( '
%s
' . "\n", $class, esc_url( get_pagenum_link( $link ) ), $link ); }                             if ( ! in_array( $max, $links ) ) {                             if ( ! in_array( $max - 1, $links ) )                                     echo '
%u2026
' . "\n";                                     $class = $paged == $max ? ' class="active"' : '';                                     printf( '
%s
' . "\n", $class, esc_url( get_pagenum_link( $max ) ), $max ); }                             if ( get_next_posts_link() )                                     printf( '
%s
' . "\n", get_next_posts_link() );                                     echo '

' . "\n"; }                              // registering custom post type (tutorials)      add_action( 'init', 'wpb_tutorials' );             function wpb_tutorials() {                     register_post_type( 'tutorials', array(                             'labels' => array(                                     'name' => 'Tutorials',                                     'singular_name' => 'Tutorial',                                     'add_new' => 'Add Tutorial',                                     'add_new_item' => 'New Tutorial',                                     'edit_item' => 'Edit Tutorial',                                     'new_item' => 'New Tutorial',                                     'view_item' => 'View Tutorial',                                     'all_items' => 'All Tutorials',                                     'search_items' => 'Search Tutorial',                                     'not_found' =>  'No Tutorial Found',                                     'not_found_in_trash' => 'No Tutorial in the trash',                                     'parent_item_colon' => '',                                     'menu_name' => 'Tutorials'),                             'public' => true,                             'publicly_queryable' => true,                             'show_ui' => true,                             'exclude_from_search' => false,                             'query_var' => true,                             'capability_type' => 'post',                             'rewrite' => array('slug' => 'tutorials/%tcat%'),                             'can_export' => true,                             'has_archive' => true,                             'hierarchical' => false,                             'show_in_nav_menus' => true,                             'menu_position' => 50,                             'taxonomies' => array('post_tag'),                             'menu_icon' => get_template_directory_uri() . '/images/icons/icon-tutorial.png',                             'supports' => array( 'title', 'editor', 'tags', 'comments' ), ) ); }             // register taxonomy             register_taxonomy('tcat', array('tutorials'), array(                     'labels' => array(                             'name' => 'Tutorial Category',                             'singular_name' => 'Tutorial Category',                             'search_items' =>  'Search Tutorial Categories',                             'all_items' => 'All Tutorial Categories',                                    'add_new_item' => 'Add Tutorial Category',                             'edit_item' => 'Edit Tutorial Category',                             'update_item' => 'Update Tutorial Category',                             'new_item_name' => 'New Tutorial Category',                             'parent_item' => 'Parent Tutorial Category',                             'parent_item_colon' => 'Parent Tutorial Category:',                             'not_found' => 'No Tutorial Category Found',                             'not_found_in_trash' => 'No Tutorial Category Found in Trash',                             'menu_name' => 'Categories'),                     'query_var' => true,                     'public' => true,                     'show_admin_column' => true,                     'sort' => '',                     'hierarchical' => true,                     'rewrite' => array( 'slug' => 'tutorials'),                     'show_ui' => true) );             // rewrite permalink - category based             function build_tutorial_permalink($link, $post) {                     if ($post->post_type != 'tutorials')                             return $link;                     if ($cats = get_the_terms($post->ID, 'tcat'))                             $link = str_replace('%tcat%', array_pop($cats)->slug, $link);                             return $link; }                             add_filter('post_type_link', 'build_tutorial_permalink', 10, 2);     ?>      `Seems like, its working just fine without any major issues. However, what's really bothering me is I couldn't get the archive page working from: **wpbloggerz.com/tutorials/**. I already have **archive-tutorials.php** file (copied from archive.php). Yes, I tried with changing the permalink structure but it didn't work. So what I did is, I created a page with "tutorials" title (with custom page template) and the permalink of that page is also wpbloggerz.com/tutorials/ (since the archive page wasn't working). It has custom pagination function which I have also included on pastebin url. The pagination is not working (gives me 404 error) even though it shows the right url structure but the same works on other pages. I have **taxonomy-tcat.php** to display posts archived with custom taxonomies which is working fine without any issues. Now, only couple of days back I came across http://codex.wordpress.org/Post_Types page and read about "URLs of Namespaced Custom Post Types Identifiers" section. The example on that page shows "acme_product" is being registered as custom post type and using the "products" slug to rewrite the permalink structure. Do you think I should have registered my custom post type as "mytutorials" (or something else) instead of "tutorials"? or something else went wrong? I am so confused. Please help. Thanks.


Update custom field value

I want to update a custom field value whenever an Editor visits a post. I want to get it done to track hits on a post by editors on my site. Not finding a proper solution or I am confused with multiple solutions. I think I can use `update_post_meta()` on single post page but not sure if it is a right solution.


Category List in Theme Options Page

I am trying to create a multi-select category list in a theme options page and everything shows up but when i save the options only the last option from the multi-select box that is selected gets saved to the database. Does someone know what I'm doing wrong perhaps? Here's bits and pieces of the code I'm currently using:               <?php          $themename_themename = "themename";     $themename_shortname = "themename";     $themename_option_group = $themename_shortname.'_theme_option_group';     $themename_option_name = $themename_shortname.'_theme_options';               // WordPress Categories via an Array         $wp_cats = array();           $categories = get_categories('hide_empty=0&orderby=name');         foreach ($categories as $category_list) {             $wp_cats[$category_list->cat_ID] = $category_list->cat_name;         }         $categories_tmp = array_unshift($wp_cats, "Select a category:");          // Create theme options     global $themename_settings;          $themename_settings = array (              // Multi-select         array(  "name" => __( 'Cat List','themename'), 'id' => $themename_shortname.'_list_cats', 'type' => 'multi-select',                 "desc" => __( 'Multi Select Unorderd Lists in content  area.','themename'),                 'std' => '',                 "value" => $wp_cats ),          );          function themename_settings_page() {                   case 'multi-select':        // Multi-select ?>

<?php echo $value['desc']; ?>
             <label for="<?php echo $themename_option_name.'['.$valueid.']'; ?>"><?php echo $value['name']; ?>                 <select name="<?php echo $themename_option_name.'['.$valueid.']'; ?>" id="<?php echo $themename_option_name.'['.$valueid.']'; ?>" multiple="multiple"  style="height:150px; min-width: 200px;">                      <?php                     $multi_setting = $options[$valueid];                     foreach ($value['value'] as $category_list) {                 ?>                         <option value="<?php echo $category_list ?>" <?php if($multi_setting != '') { selected($options[$valueid] == $category_list );} else {  selected($options[$valueid] == $value['std']);} ?>><?php echo $category_list; ?></option>                     <?php } ?>                 </select>
             <?php         break;           } // --themename_settings_page      Here is a temp. screenshot of what is going on: Screenshot Any help would be very appreciated.


Copying wordpress to another server breaks it on original server

I am working on a new version our site. Today I was going to put the blog on the new version. Our current website and the successor I am building are on different servers and accessed by different domain names. So what I did was import the database the blog uses into the dev site. Then I copied all the files and put them on the dev site. On the dev site I went to /blog/wp-admin and I changed the general settings so the blog URL would use the dev domain. I made **NO CHANGES** on the current production website server. However the current production website's blog is now broken. When I go to blog/wp-admin on the real site, the form posts to the dev server. I am not able to log into wordpress on either the dev or production site now. I do not understand how I could break anything on the production server by making changes on a completely separate server that is unrelated to the production server. So my main goals now are to:   1. **Restore the blog on production server (undo the changes I made today) and get it working again right away.**   2. **Figure out what I did wrong so I can put the blog on the production server.**


How to sort all admin sub menu items in a custom order

i tried this solution given for this question Re-ordering Admin Submenu Sections to sort sub menu items of all top level menus. But i don't get it to work. I have an array of custom ordering of menu items with which all sub menu items needs to be sorted.               $custom_order = array(     array('edit.php' => array(15, 10, 5, 16)),      array('upload.php' => array(10, 5)),      array('edit.php?post_type=page' => array(10, 5)),      array('themes.php' => array(7, 5, 6, 12, 10, 11, 13)),     array('options-general.php' => array(15, 20, 10, 30, 40, 35, 25))     array('el_admin_main' => array(3, 5, 1, 4, 2)),      );      I am also including plugin menu items(example: 'el_admin_main') dynamically to the above array. So i am looking for a function to sort all sub menu items according to the above array. Any help would be greatly appreciated.


How to use photo in multiple posts?

I have a theme that shows images only from gallery tab (so i can't re-use an image to other posts). As you know an image can only get attached to 1 post. I found a plugin that you can attach an image to more posts, but it doesn't work for this theme. to conclude: I am looking for a way to use the same photo file in more than one post? thanks ;-)


Page menu with one image link instead of page title?

I have the following code generated by wordpress for my nav1:

Inicio

Quienes Somos

Servicios

Inteligencia

Personal, Equipos, Armamentos

Seguridad Operativa

Contacto

Cotice su stand en ferias

      And I would like the last `<li>` tag under the title of "Cotice su stand en ferias" to use a button instead of text as the rest of the `<li>`'s. Is there a way to accomplish this without having to completely remove that item and placing a button next to the `#nav1`? Thanks for the help in advance. Edit: got it.               #nav1 ul li:last-child {background: url(images/cotizacion-icono.jpg) no-repeat scroll;}


Query posts using custom taxonomy and selected terms

I'm not able to use array for the terms in the following query, only a single term:                   $args=array(         'facts' => 'information', //taxonomy:facts and term:information         'post_type' => 'book',         'post_status' => 'publish',         'posts_per_page' => -1,         'caller_get_posts'=> 1         );         $my_query = null;         $my_query = new WP_Query($args)      Is this normal behiavour? Is there any equivalent method for selecting posts with certain terms from custom taxonomy with custom post type?


Call Shortcode inside another Shortcodes callback

I'm using a plugin that shows content only to specific user roles. This content is surrounded by a shortcode tag to make it invisible to other other user roles. Now I'd like to call other shortcodes inside that restricted content. I understand that I need to set the plugins shortcodes up so that they use `do_shortcode()`, but there are so many files that I'm not sure exactly where to do this. All of the places I've tried have not made any change. Any tips on what to look for? Here's the code block I found. I think this is what I need to edit. What do you think? Change this: `return stripslashes($message);` Change to: `return stripslashes(do_shortcode($message));`               // Show the level based protected shortcode message         function do_levelprotected_shortcode($atts, $content = null, $code = "") {                  global $M_options;                  // Set up the level shortcodes here             $shortcodes = apply_filters('membership_level_shortcodes', array() );             $notshortcodes = apply_filters('membership_not_level_shortcodes', array() );                  $code = strtolower( $code );                  if( substr( $code, 0, 4 ) !== "not-" ) {                 if(!empty($shortcodes)) {                     // search positive shortcodes first                     $id = array_search( $code, $shortcodes );                     if($id !== false) {                         // we have found a level so we need to check if it has a custom protected message, otherwise we'll just output the default main on                         $level = new M_Level( $id );                         $message = $level->get_meta( 'level_protectedcontent' );                         if(!empty($message)) {                             return stripslashes($message);                         }                     }                 }             } else {                 if(!empty($notshortcodes)) {                     // search positive shortcodes first                     $id = array_search( $code, $notshortcodes );                     if($id !== false) {                         // we have found a level so we need to check if it has a custom protected message, otherwise we'll just output the default main on                         $level = new M_Level( $id );                         $message = $level->get_meta( 'level_protectedcontent' );                         if(!empty($message)) {                             return stripslashes($message);                         }                     }                 }             }      * * * _EDITORS NOTE: I removed all the links to the (closed source) plugins as they're as relevant for the actual question as the plugins source code is accessible: zero._


// File Security Check from WooCommerce

// File Security Check     if ( ! empty( $_SERVER['SCRIPT_FILENAME'] ) && basename( __FILE__ ) == basename($_SERVER['SCRIPT_FILENAME'] ) ) {         die ( 'You do not have sufficient permissions to access this page' );     }      I see this at the top of every php file in WooCommerce. Can this be used in every theme file or plugin file as well? Does that make any sense to even use it this way? In what way would you use this block of code mostly? Thanks!


Show sidebar from custom meta value

I want to show sidebar from meta value.Basically I am using wp-page-widget.Now I want to show the active widget.Since I am working on one page template so general procedure will not work. Upon inspection I found there is a meta value created.My debug out put               $d= get_post_meta( get_the_ID(), '_sidebars_widgets', false );     var_dump( $d);      Which output               array (size=1)     0 =>      array (size=3)     'wp_inactive_widgets' =>      array (size=0)     empty     'sidebar' =>      array (size=2)           0 => string 'hc_text-5' (length=9)           1 => string 'recent-comments-2' (length=17)       'array_version' => int 3      It shows that I have two active widget on sidebar.Now I want to grab these.


Change the login button on the login page

I would like to be able to change the text on the Log In button in wp- login.php - however, it's a bit more complicated than that. I want to be able to change it in the theme, rather than editing the core file directly, so that a) It doesn’t get overwritten when WordPress updates, and b) It'll transfer over if I distribute my theme at all. I don't know if that's possible. All I can find on the internet is how to change the CSS of the login page, not the actual HTML/PHP.


sticky post in custom loop

I have a problem with showing sticky posts in a custom loop. This is the code I'm using to for the custom loop:               <?php         $post_from_cat_a = new WP_Query(array(          'category_name' => 'events',  //Get posts from category a         'posts_per_page'=> 2 //Limit it to the latest one         ));              if( $post_from_cat_a->have_posts() ){             while( $post_from_cat_a->have_posts() ): $post_from_cat_a->the_post(); //Display output here for post from category a         $category = get_the_category();          if($category[0]){         echo '
term_id ).'">'.$category[0]->cat_name.'
';         }              get_template_part( 'content', 'events' );          endwhile;         }     ?>                I can't figure it out why it doesn't work. **Later edit:** this is my entire homepage.php where the problem occurs and this is the content-events.php file used for each post in the events category. **Second edit:** If I include `'post__in' => get_option('sticky_posts')` in the `wp_query` array the sticky post is shown but it doesn't list the next post in the category. Only the sticky posts appears on the page, it's kind of ignoring the `'posts_per_page'=> 2` argument. Does anyone have any idea why this is happening?


Is it breaking the GPL if you remove license.txt before uploading?

My hosting account has a file limit so, to reduce files I don't bother uploading the licence file. Is this breaking the GPL License? I am not redistributing it without the license or anything just using the code.


Meta Box Plugin Cloned Fields - Multiple Foreach values

I have the following code that I can't get working. I have two cloneable fields that are being output as one entity (URL and thumbnail image). These are cloned fields using the Meta Box Plugin by Deluxe Blogging, so I need to be able to do an if statement if there is nothing at all and then I need to be able to repeat the thumbnail and URL twice (if there are two separate entries).               <?php if      $videoID = get_post_meta( $post->ID, '_danieltiger_repvid', true );     $videoThmb = get_post_meta( $post->ID, '_danieltiger_repthmb', true );         foreach ( $videoID as $value )             {                 echo '
';                 echo '';                 echo '';                 echo '<img width="157" height="88" alt="<?php the_title(); ?> image" src="';                 echo $videoThmb;                 echo '" />';                 echo '
';             } ?>          <?php } ?>      The example code from Deluxe Blogging on outputting cloned fields is the following:               $metas = get_post_meta( get_the_ID(), 'meta_key', true );         foreach ( $metas as $meta )          {              echo $meta;          }      I can't seem to figure out how to work in the two separate values. I have another field I'm cloning and outputting in my theme correctly but I just can't get the gist on this one. TIA!


How do I make page URLs look like "www.site.com/page" instead of "www.site.com/blog/page" but have post URLs stay "www.site.com/blog/post"?

I would like to make it so the URLs of my pages (created in the Wordpress dashboard) show up right after the domain name instead of after the blog directory. I have installed Wordpress in a directory called **blog** which is located in the **public_html** directory. When I make a _page_ from the Wordpress dashboard it will by default appear under the blog directory like:               www.site.com/blog/page      What I would like to do is take advantage of Wordpress's built in 'pretty URL' styling but use them outside of the **blog** directory where Wordpress is installed. So for example:               www.site.com/page      When I try to manually create a page, add it in public_html directory and view it on my site it looks like:               www.site.com/page.html       I don't like the trailing `.html` because it is not clean looking and just extra unneeded info for the visitor. _**UPDATE:_** Also keep in mind that I would also like to keep the URLs of each _post_ looking like:               www.site.com/blog/post      So to sum it up:   **How can I make my Wordpress _page_ URLs look like** `www.site.com/page` **while having my Wordpress installed in** `www.site.com/blog` **as well as having my _post_ URLs looking like** `www.site.com/blog/post` **?**


Adding a Widget : what to put in plugin URL

I am signing up to add a widget to wordpress.org here: http://wordpress.org/extend/plugins/add/ What do I put for the field "Plugin URL"? Would that URL be the svn repository I am currently hosting my widget (a personal svn repo) or would that be a URL of a website where the widget is being used?


changing variable through filters or action hooks

it appears i have a problem with understanding how add_action,add_filter and apply_filters work. somewhat abbreviated, i have the following scenario: in a template file i have this               while ( $the_query->have_posts() ) : $the_query->the_post();         /*get meta data for this post**/         $meta=get_post_meta(get_the_ID(), $post_type, true );              /***             at this stage - amongst other things - print_r($meta) returns             Array ( [prices] => Array ( [0] => 8 ) )         ***/              /**add add_action hook to change $meta (if possible)**/         do_action('alter_loop',$meta);              /***             AFTER executing this action I would like to have print_r($meta) return             Array ( [prices] => Array ( [0] => 5 ) )             but it still returns             Array ( [prices] => Array ( [0] => 8 ) )         ***/              /* more things*/          endwhile;      in a class i have the following:               function __construct() {         add_action('alter_loop', array( $this, 'alter_loop_meta'),10,1);     }               function alter_loop_meta($meta){         add_filter('some_identifier',array($this,'my_filter'),10,1);         $meta = apply_filters('some_identifier',$meta);         /***             at this stage print_r($meta) DOES actually return             Array ( [prices] => Array ( [0] => 8 ) )         ***/              return $meta;     }     function my_filter( $meta ) {         $meta['prices'][0]='8';              return $meta;     }      if I use               global $meta;       in the template file it works (and i can save myself all this filtering as i can just set $meta['prices'][0]='8'; in alter_loop_meta). however, i am wondering if there's a way to achieve this without any global variables. any hints / links etc much appreciated and - of course - happy to provide more code if necessary ...


Editing does not change post_name

Suppose I wrote an article, "My Article Title", it has been saved into the database with `$post_name=my-article-title` , and the permalink is `mysite.com/my-article-title`. All good. Now, if I didn't like the title and change it to "Title of my article", I expect the post name and the url change accordingly. So the url should become `mysite.com/title-of-my-article`, however, it remains as `mysite.com/my- article-title`. So how do I set it to change? Should I add a meta box somewhere? Or is there a plugin for this? Thanks !


Moved a site to a new server with a new SSL cert and now admin will not load

I moved site over to a new server with a new ssl cert, but the same domain. I am now seeing the following when trying to load the site with https in Chrome:               Error code: ERR_SSL_PROTOCOL_ERROR      It turns out that the previous developer forced https somehow on the site for admin and I'm not seeing anything in `.htaccess` that would indicate that it's forcing the rewrite for admin. Any ideas how to track down and resolve an issue like this?


Displaying BLOB PDF File

I have some pdf files that are stored in the wordpress database as a blob and I need to display these files. The files are not linked to any posts directly. The code I have currently is:               <div class="wrap">     <?php     global $wpdb;          $mydataset = $wpdb->get_row("SELECT * FROM wp_attachments WHERE ID = 1119");          $recordID = $mydataset->ID;     $FileType = $mydataset->FileType;     $FileSize = $mydataset->FileSize;     $FileName = $mydataset->FileName;     $FileContent = $mydataset->FileContent;          add_action( 'send_headers', 'add_header_info' );     function add_header_info() {     header("Content-Type: ". $FileType);     header("Content-Length: ". $FileSize);     header("Content-Disposition: attachment; filename=". $FileName);     echo $FileContent;     }           echo $FileContent;     ?>      The problem is that the I do not get the normal open/save file dialogue box from the browser, but rather I get a whole lot of:               %PDF-1.5 %���� 21 0 obj <> endobj 36 0 obj <>/Filter/FlateDecode     /ID[<3D64A2F9453F2A4097AB5FEE91CB4D65>]/Index[21 22]/Info 20 0 R/Length 78/Prev       58282/Root 22 0 R/Size 43/Type/XRef/W[1 2 1]>>stream h�bbdb�$��V �\"�@�M��k�x     "n���A�d��R �HLfbdXcD'�3���a  endstream endobj startxref 0 %%EOF 42 0 obj      <>stream h�bc2df`H�g�a@& �x�(�x���9X����YH�1     X������CC�C���A�As�d�+,��$��p00��iF �bn��&�� ��q� endstream      endobj 22 0 obj <> endobj 23 0 obj <> endobj 24 0 obj <>stream hތS�n�@��yLT�{�     Ɏc�m�X�mĬ)*�����,�-      Can anyone please advise me on how I can correctly display the BLOB data?


Order custom Taxomony alphabetically and reversal after clicking a button?

I made a custom type named foods and a taxonomy named fruits. I want to order the fruits name alphabetically ( A-Z ) on clicking a button and then clicking on it again it will show Z-A order. Can you tell me how to do it please?


Update Custom Taxonomy Value for a post based on custom date field

**Quick read:** I need to update the value of a custom taxonomy based on two custom field values (dates) automatically, meaning the post updates itself with having to click "update" to change the value. **Long details:** I have created a new private taxonomy called event_status. The possible values are "opening_soon", "playing_now", and "closed". This taxonomy is attached to a custom post type named "event". When a post of this type is created, there is a set of custom fields (using advanced custom fields plugin) that is filled out. One is "Start Date" and the other is "End Date". This is the first and last performances of the Event. When an Event post is created, the taxonomy event_status is set to "opening_soon" (as the event hasn't happened yet). What I need to do is change the value of the event_status taxonomy based on the comparison of the current date with the start or end date of the event, as set via custom fields. I can figure out how to do this by hooking into wp_update_post() but the problem is I want the post status to be updated **automatically** without me having to hit "Update Post" for it to change. It should just changed based on the current date. Hopefully there is a way to do this. I was previously trying a solution with a simple function to determine the post status, but soon figured out that I couldn't use a function to query with (obviously) so I'm going for the taxonomy solution instead so I can query for posts by that. Here is the function I'm currently trying to make work to update the taxonomy on save_post, but this isn't quite working yet either. The bottom portion is for events that only have one performance (so the end_date field is empty) and the top deals with events that have a start AND end date.                   //Set post_status based on the current date on wp_update_post()     function set_event_status($post_ID) {         $start = strtotime(get_field('start_date'));          $end = strtotime(get_field('end_date'));         $now = strtotime('now - 7 hours');         if ($start && $end) {             if (($start <= $now) && ($end >= $now)) {                 $status = 'playing_now';             } elseif ($start >= $now) {                  $status = 'opening_soon';             } elseif ($end < $now) {                 $status = 'closed';             }         } elseif ($start) {             if ($start <= $now) {                 $status = 'closed';             } elseif ($start >= $now) {                 $status = 'opening_soon';             } elseif ($start == $now) {                 $status = 'playing_now';             }         } else {             $status = 'closed';         }         wp_set_post_terms( $post_ID, $status, 'event_status' );              return $post_ID;     }     add_action( 'save_post', 'set_event_status' );


loading custom.js file after jquery is loaded

I am adding a javascript file through the functions.php file. I am using the method as suggested on Wordpress Codex. One question I have is that what is the best way to handle the version number column. Is it recommended to send the version of jquery or the version of the script I am loading? Using this code.               <?php     function my_scripts_method() {     // register your script location, dependencies and version        wp_register_script('custom_script',        get_template_directory_uri() . '/js/custom_script.js',        array('jquery'),        '1.0' );      // enqueue the script       wp_enqueue_script('custom_script');       }     add_action('wp_enqueue_scripts', 'my_scripts_method');     ?>


exec-PHP shows output at bottom of page

I'm using the latest Wordpress release with the default theme. I have a function similar to this which is included and called from within a page (using exec-PHP).               <?php function myFunc($value) {             while () // some condition {                  echo $value;             }      ?>      <?php myFunc('val'); ?>      the output of the `echo` function is appearing at the bottom of the page instead of appearing within the correct page content section. How can I fix this?


title_save_pre on post publish

I'm trying to build the title of a custom post using the values within post custom fields. The problem is that using `title_save_pre` only executes when I update the post, not when I create it. When I create the post I get the title : **(no title)** If I edit and save I get the right title. I need to get the right title in backend. This is my code:               function update_phone_title($title) {          global $post;          $type = get_post_type($post->ID);          if ( 'phone' == $type) {         $title = get_post_meta($post->ID, 'manufacturer', TRUE);         $title .= ' '.get_post_meta($post->ID, 'model', TRUE);         $title .= ' '.get_post_meta($post->ID, 'memory', TRUE);     }           return $title;     }     add_filter ('title_save_pre', 'update_phone_title');      FIXED using wp_insert_post_data .I did it with this code:               function filter_handler( $data , $postarr )     {       global $post;       $id = $post->ID;            if('phone' == $data['post_type'] && isset($data['post_type']))         if($id) {             $title = $_POST['fields']['field_4fd2897fc0bfe']. ' ' . $_POST['fields']['field_4fd2897fc2328'] . ' ' .$_POST['fields']['field_4fd2897fc273a'];             $data['post_title'] = $title;         }       return $data;     }          add_filter( 'wp_insert_post_data' , 'filter_handler' , '99', 2 );


Why would a completely normal loop give offset errors and maximum execution time errors?

I'm too angry about this problem to see it straight anymore, so I'm guaranteed to be overlooking something simple. Please help. Here's all my code has been stripped down to:               <?php          $home_gallery = new WP_Query(array(     "posts_per_page" => 2     ));          if ( $home_gallery->have_posts() ) : while ( $home_gallery->have_posts() ) :           //the_post();          //if (get_post_meta(get_the_ID(), "_is_front_page_gallery", true) == "true") {         //the_content();         //exit;     //}          endwhile;     ?>     <?php endif; ?>      Trying to run this code on the front page of my WordPress site has causes my CPU to spike, my fan to run hot, and one of two errors to surface. Either I get a long string of "Offset = 10" errors (can't recreate that one right this minute so I can't copy/paste) or more recently I'm just getting this: > Fatal error: Maximum execution time of 30 seconds exceeded Any ideas anyone has I would be happy to hear. It's running on my localhost and has worked fine up until this afternoon. . The problem seems very similar to this one: Repetitive Error: Maximum Execution has exceeded 30 secs which was closed for being unhelpful. :(


ajax in wordpress - path issue

am trying out a bit of ajax ( via jquery ) in wordpresss. ... i have everything working correctly but for some reason i have to have the full url to the php handler file even though it's located in the same directory as the script here's the code $.post('http://full/url/to/file.php', $("#form").serialize(), function(data){ do stuff ... }); why cant i just put "file.php" into that - why does it need the full url .... or more importantly what can i put in there that would work on any site without the end user having to put in the full url every time ps i have read the problem with ajax and the path to the php page but i just got a bit more mixed up - i have also read the ajax in plugins page on the wp codex but i couldnt see a relevant example in there .... i'm suspect this mught have something to do with wp_localise_script but im not sure thanks