Custom post type: can't enable comments by default

I want to enable comments for custom post types just like they are for standard posts, but can't seem to get it to work. In functions.php, as part of registering my custom post type, I have this:               'supports' => array('title', 'author', 'thumbnail', 'comments', 'revisions'),      In my single post type template I have this:               <?php comments_template( '', true ); ?>      But on the edit screen "allow comments" is un-checked by default which results in a "comments are closed" message on the front end. When I check "allow comments" then comments are enabled on the front end, but I really don't want to tell my client he has to manually check that box for every new post. I tried the recommendations here: Why are the comments disabled by default on my custom_post_types? But it didn't work for me. I tried disabling all plugins. Didn't work. Using WP 3.6. Any suggestions? Thanks in advance.


get images from post and make a zip

here is what i have so far.                 function zip_gallery()       {           global $post;           $images = get_children(array('post_parent' => get_the_ID(), 'post_type' => 'attachment', 'numberposts' => -1, 'post_status' => null, 'post_mime_type' => 'image', ));                if ($images) {               $save = $post->post_title;                    $zip = new ZipArchive;               if ($zip->open($save . '.zip', ZIPARCHIVE::CREATE) === true) {                   foreach ($images as $image) {                       $file = wp_get_attachment_url($image->ID, 'full', false, false);                       $filename = pathinfo($file);                       $zip->addFile($file, $filename);                   }                        $zip->close();               }           }       }           can someone shed some light on what im doing wrong.


eLearning Module

Is there a good eLearning module? ie. Create classes, quizzes, grades, etc. I'm just scanning for general information right now. Thanks!


Many to Many Taxonomies or rewrite rules?

Im developing a theme for article directory and i would like to link some way taxonomies to taxonomies. I had a custom post type called " **company** " with 2 taxnomies               Taxonomy #1 is category with terms(shops,workshops,churchs,shoppings,etc)          Taxonomy #2 is location with terms(New York, New jersey,Miami, etc)      With taxonomy #1 i can do               local.dev/category/shops/ to list all shops      With taxonomy #2 i can do               local.dev/location/miami/ to list all companies in miami      Currently i got working by this answer of MikeSchinkel the following:                local.dev/shops/      Which i can use also like these to retrieve my desired results:               local.dev/shops/?location=miami      BUT i would like to do               local.dev/shops/miami or      local.dev/shops/new-york to list shops in different locations       Making all the urls looks nicer. Is this possible? **My terms will be all unique** so im sure they will not collide with posts tags or slugs or anything Probably the best thing is to create a rewrite rule right? Please give me some light on this, im a bit lost.


Create an RSS feed of all posts

I'm fairly new to Wordpress and I'm just wondering how to create a RSS feed of all posts. Are there plugins for this? Is this something I have to change in code? etc... I'm trying to implement my Wordpress posts with `Hootsuite`, so that when I make new posts in Wordpress, `Hootsuite` will automatically post them on my social media websites through RSS. Any help is much appreciated


Use post thumbnail as div background

I'm having trouble implementing a way of using the set WordPress post thumbnail as a background for a div which will include the whole post. Basically, I need a way to call for the thumbnail URL in the index.php file. Something like this               <div style="background: url(<?php if ( has_post_thumbnail() ) { the_post_thumbnail( 'normal-bg' ); } ?>) ">      Now what should happen is that the above would find a thumbnail for the post and use it as the background image. The thumbnail class would be "normal-bg", since there are thumbnail classes in my functions.php with different heights (since some posts can have more text etc.). However, I've been unable to make the above code work. Sorry if the whole concept sounds confusing, it's a bit too hard to explain :)


multiple taxonomies in wp_list_categories' $args

Why doesn't it shows terms in both 'lunch' and 'dinner' taxonomies?   How can i do it?                 <?php          $taxonomy     = array('lunch', 'dinner');         $orderby      = 'name';          $hierarchical = 1;          $title        = '';              $args = array(           'taxonomy'     => $taxonomy,           'orderby'      => $orderby,             'hierarchical' => $hierarchical,           'title_li'     => $title         );         ?>              <ul>         <?php wp_list_categories( $args ); ?>         </ul>


Comment Reply javascript

I am working on a client site which is a very stripped down theme. It has no standard html markups as a result of which the reply box doesn't move upto the place of being just below the comment to which you hit the reply button. Can anyone point me to the minimum markup required? I am trying to add classes one by one. **Trying to explain it better:** I click on the reply button, the page reloads and the comment form stays below all the comments list. I want it to make it work like when we click on reply button, then without any page reload, it jumps up there and can be cancelled back to the place. The default what we have in Twentyten **Update:** I managed to fix up the markup and now I am using comment_form() but cancel reply button doesn't appear and I am not filtering that out. Any ideas? **Done** So sorry to trouble everyone here. The last issue was fixed by removing the CSS `display:none;` ( Lesson - DIY Themes sucks unless its what you do! ;) )


Using a loop to display terms associated with a post

I'm using a custom post type and custom taxonomies, and using the following to display the terms of the taxonomies on the post page:               the_terms( $post->ID, 'taxname', 'beforetext', ', ');      Is there a way to loop through all the taxonomies assigned to this post and display the terms in an unordered list, rather than a separate line in functions.php for each taxonomy? I suspect that this can be done with a foreach loop, but I don't know the right syntax.


Custom wp_welcome_panel for every role or custom dashboard

I would love to customized and dumb down my dashboard with custom icons, shortcuts, guides, etc. I can do this already using widgets, but I would like to dare and do something better. wp_welcome_panel on this regard, is awesome: I can customized it, I can make it show whatever I want but... only administrators can see this. So I was wondering: 1) Can I customize wp_welcome_panel so that every role can actually see it? 2) Can I add some code before the widgets in order to create a custom dashboard header similar to the one in wp_welcome_panel)? I already tried with               function mycustomcontent() {         echo '
Hello world
';     }     add_action('load-index.php', 'mycustomcontent');      But... the HTML output is placed before anything (right after the body tag), even pushing down the sidebar. Thanks in advance


Dashboard Widget drawn before opening HTML tag

I am making my first dashboard widget and it is displaying successfully but the output HTML from the function below is showing up before the opening HTML tag on dashboard page. The code involved is below. Do I need some init call prior to the add_action() call?               function example_add_dashboard_widgets() {         wp_add_dashboard_widget(                      'donationsmtcarmel',         // Widget slug.                      'Mt. Carmel Donations',         // Title.                      'draw_widget' // Display function.             );        }     add_action( 'wp_dashboard_setup', 'draw_widget' );               function draw_widget() {         $dObj = new Donation;         $donations = $dObj->retrieve("`paypal_txn` != '' AND `archived` = '0' ORDER BY `date` DESC");         echo '

Mt. Carmel Donations

';          echo "
Recent Donations:

";          if ($donations) {              foreach ($donations as $d) {                 echo $d->donor_name.'   $'.$d->tx()->mc_gross.'   '.date('n/j/Y g:i A', strtotime($d->date))."
\n";             }          } else {              echo 'None.';          }               echo '

Donations Page

           ';          }


Unable to access wordpress login.php

I has been completed a theme for a client. I Used to access the live wp-admin page using **http://name.myname.com/wp-login.php** But that page shows just a blank(white) page. How to get fix that? Note: Their hosting provider is supporting wordpress. The error now generating is:               Parse error: syntax error, unexpected '?>' in /home/mysitee/public_html/mytheme/wp-content/themes/theme name/include/widget.php on line 1


After retrive password, redirect to index page

I'm using wordpress 3,8. When a user visit /wp-login.php?action=lostpassword and clicks "retrive password" i would like do redirect them to /index.php instead of the login window. Is it possible? Regards Daniel


Running several WordPress sites on same core / plugins?

Is it possible to run more than one site on the same WordPress core and a set of plugins? I want to be able to have custom plugins and themes for each site, but have a base set that is the same, to make it easier to maintain.


What is the best permalink structure for SEO?

In the past I've used the Day and Name or Month and Name settings. Should the date structure be omitted and just have /%postname%/ ? Ie does having the date information reduce the quality of the url?


How to use Multiple-Domains in one Multi-Site Installation?

I have created a Multi-Site and want to help my friends to create Sub-sites under it.I also have Idea to offer 3 choices to chose from the domain names they wish . > For Example : My main site is mydomain.com .They should have an option to > chose from domain1.com,domain2.com and domain3.com . I have googled for any instructions on it and got this one on wpmudev.But I would like to set this functionality with any plugin which I can get free of cost or configuring manually .Do any one Implemented this ever before? Once I read similar questions some where but I have not find a right solution .


Calling directories to load in wordpress

I have a wordpress install, with two sub folders "assets" and "functions" these folders contain important files for the wordpress theme. What would be the best way to load these files I've tried something like this which live in a file called constants.php in my root directory                   define('CSS_DIR', get_stylesheet_directory() . '/');         define('FUNCTIONS_DIR', get_stylesheet_directory() . '/');      then in my functions.php file i've got `require_once(FUNCTIONS_DIR . 'functions/news.php');` Hope this is clear what I'm trying to achieve. _updated with errors_ I seem to be getting the following errors.               Warning: require_once(FUNCTIONS_DIR/functions/news.php): failed to open stream: No such file or directory in /home/foxyrent/public_html/wp-content/themes/foxyrental/functions.php on line 21          Fatal error: require_once(): Failed opening required 'FUNCTIONS_DIR/functions/news.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/foxyrent/public_html/wp-content/themes/foxyrental/functions.php on line 21


add_filter for specific pages

Is it possible to add this filter `add_filter("the_content", "magicalender_get_event_page");` But only for one specific page, for example `if($post->post_name == "magicalenderpage")` If I put the if statement inside the function, then on any other pages the content isn't displayed - and with an else statement afterwards that echoes out the content of the page otherwise I encounter problems where it interferes with other plug-ins that also do things with `add_filter("the_content", "foo");` The magicalender_get_event_page function is as follows               function magicalender_get_event_page(){         global $wpdb;         global $post;              if($post->post_name == "magicalenderpage"){             echo "
";             for($i = 0; $event = $wpdb->get_row("SELECT * FROM ".$wpdb->prefix."magicalender", ARRAY_A, $i); $i++){                 echo"

".$event['event']."

".date('m/d/Y', strtotime($event['dmy']))."

".str_replace("&", "&", str_replace("'", "'", str_replace(""", "\"", $event['desc'])))."

                 ";             }             echo "
";                  $o = $wpdb->get_row("SELECT * FROM ".$wpdb->prefix."magioptions", ARRAY_A);             echo"                              ";         }         else{             return $content;         }     }


Giving users an editable homepage/business directory

I'm currently working on a site which requires a business directory for 80 tennants. In an ideal world I'd like the administrator to create a user for each business and a page in a custom post type. The user would then be restricted to editing and updating only that page. On the front end these posts would be listed on a page which is searchable. Has anyone encountered such requirements in the past, any tips, ideas. All feedback welcome.


Permalinks without subdirectories

Today I use: permalink_structure: /%postname% This gives me URL like this on my pages:   1. #http://www.mypage.com/page1   2. #http://www.mypage.com/page1/page2   3. #http://www.mypage.com/page1/page2/page3 But I want it to be:   1. #http://www.mypage.com/page1   2. #http://www.mypage.com/page2   3. #http://www.mypage.com/page3 How can I make this happen? I still want to use the parent function in wordpress admin... **The reasons why I want this are:**   * It looks so much better   * When I (or some one else) change URL of page1 I am not messing up the URL for page 2 and page3 (less 301 work)   * (Better SEO)


List of Categories for Custom Post Type

I'm wanting to create a list of categories for a custom post type in Wordpress. The custom post type is 'Books' and this has been set-up using the standard `taxonomies' => array( 'category', 'post_tag' ),` I'm not sure if there is a way to make `<?php wp_list_categories(); ?>` just show catgories from the post-type books. I don't want to have to create a custom taxonomy as well. Thoughts?


.htaccess and 500 error, extra character added

I am having a weird problem. Every few days I go to my website and get an "Internal Server Error" - Or 500 error. I go into the .htaccess file of the site and notice it's been altered. One character is added at the end of the file. It's easy to fix and continue on, but it keeps happening. htaccess permissions are 644 and the error logs don't say anything about this so I don't know where to start. Anybody have an idea as to what's going on or point me to some information on this issue? here is the "altered" htaccess code:               # BEGIN WordPress     <IfModule mod_rewrite.c>     RewriteEngine On     RewriteBase /     RewriteCond %{REQUEST_FILENAME} !-f     RewriteCond %{REQUEST_FILENAME} !-d     RewriteRule . /index-php [L]     </IfModule>          # END WordPress     s <---See This?!


Home not showing in yoast breadcrumb

I have created a page named home and assigned a template file named Homepage to it. I am using `yoast breadcrumb` to display breadcrumb. But Home is not included in it. How to fix this?


TinyMCE in Custom Metabox not loaded after upgrading from WP 3.1.4 to WP 3.2

I want something very simple: a custom metabox with a TinyMCE editor in it. The following code help me achieve that easily in 3.1.4:               add_action( 'add_meta_boxes', 'add_metaname_box');     function add_metaname_box() {         add_meta_box(             'metaname_id',             __( 'metaname text', 'metaname_textdomain'),             'metaname_custom_box',             'post'         );     }          function metaname_custom_box() {         global $post;         wp_nonce_field( plugin_basename( __FILE__ ), 'metaname_noncename' );         $data = get_post_meta($post->ID, 'metaname_custom_box', true);         echo <<<EOT         <textarea id="metaname_custom_box" name="metaname_custom_box" class="theEditor">$data</textarea>     EOT;     }      This is what it looked like:   ![Visual editor in custom meta box](http://i.stack.imgur.com/qaWCI.png) My problem is that this code is no longer works after I **upgraded from 3.1.4 to 3.2**. This is the result for the same code after upgrading to 3.2:   ![Regular textfield in custom meta box](http://i.imgur.com/1aaza.png) The HTML code for TinyMCE is not generated anymore. However, I noticed that this piece of code still works fine in **a fresh installation of WP 3.2**. This is the result of the code in fresh installation:   ![Visual editor in 3.2 style in custom meta box](http://i.stack.imgur.com/5mmZc.png) Can someone help me why my code works fine with 3.1.4 and fresh 3.2, but not in the 3.2 upgraded from 3.1.4 ? How to solve this problem?


Query counting excluded category on paged loop

I have an Index.php with a basic loop with this query before:               <?php         $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;         $args = array(           'category_name' => 'work',           'orderby' => 'asc',           'paged' => $paged         );         query_posts($args);      ?>      Which works. But when I count the amount of pages using max_num_pages it says there are 5 pages worth of posts in the 'category_name' => 'work' but I know that there are not and whats happening is its including the other posts outside of this category. How do I stop that from happening and get the loop to just display the actual amount of pages containing posts categorised with 'work' only?


My WP_Query didn't work after upgrading to WordPress 3.2

I created a custom loop using WP_Query for my featured content slider.               <?php     $slider_query = new WP_Query();     $slider_query->query("posts_per_page=5&tag=".(get_option('cgr_slider_tag'))" ");?>     <?php while ($slider_query->have_posts()) : $slider_query->the_post(); ?>
               ....      It works fine in previous 3.1.4 , but after upgraded to 3.2 that code is just didn't work. No error found in WP_Debug mode, and Then i try to directly assign the tag name without using the get_option :               <?php     $slider_query = new WP_Query();     $slider_query->query("posts_per_page=5&tag=tag1");?>     <?php while ($slider_query->have_posts()) : $slider_query->the_post(); ?>
                 ....      it works, so i assume the problem is the get_option thing. I've checked the database and other part of the theme that also using get_option and found no problem. I start thinking that the problem is I didn't code the get_option part correctly, i'm php noob so maybe it's about encapsed string or others. Any help will be appreciated.


How to display posts month by month?

How could wp-query be used to show posts month by month, and have it only show the past year? Or is it possible some wp_archive hack could handle this?


Attaching a Custom Taxonomy to Posts?

Say a plugin creates a custom taxonomy and attaches it to some custom post type. Is there a safe way to attach that same taxonomy to Posts?


How to sync to custom taxonomies (tag structure)

I have two taxonomies: "Contributers" and "Narrators." I want to sync the terms in these two taxonomies identically, so much so that I wish to be able to click on "Edit Term" and see the information (Description, Title, slug, etc.) duplicated in the partnering taxonomy. Right now, I have this (below) which does indeed insert the term with identical slug and even identical term_id (instead of appending the slug with a number), however the Description does not sync (as they are different term_taxonomy_id's. All thoughts and suggestions are welcomed!               /**      * Syncs the Contribute/Narrator Terms      *      * @param int $term_id      * @param int $tt_id      * @param string $taxonomy      * @return string      */     function lp_duplicate_created_terms( $term_id, $tt_id, $taxonomy ) {         if ( $taxonomy != 'contributer' && $taxonomy != 'narrator' )             return;              static $count = 0;              $term = get_term_by( 'id', $term_id, $taxonomy );              $opposite = ( $taxonomy == 'contributer' ) ? 'narrator' : 'contributer';              // Prevents function from running a second time in the following wp_insert_term         if ( $count > 0 )             $count = 0;         else             wp_insert_term( $term->name, $opposite, array( 'slug' => $term->slug, 'alias_of' => $term->slug, 'description' => $term->description ) );         $count++;     }     add_action( "created_term", 'lp_duplicate_created_terms', 10, 3 );


How to deal with apostrophes

I'm doing an INSERT into a wordpress table and anything with an apostrophe is coming out               It\'s true      I tried using htmlspecialchars but I'm still getting the backslash. Is there any way to write it so that the user sees               It's true      While the table in the database sees:               It\'s true      Below is my insert code:               global $wpdb;                     $table =    'wp_nc_location';                     $data =     array(                                 'name' => $name,                                 'street_no' => $street_number,                                 'street_name' => $street_name,                                 'city' => $city,                                 'province_state' => $province_state,                                 'postal_code' => $postal,                                 'country' => $country                                 );                      $format =   array(                                 '%s',                                 '%s',                                 '%s',                                 '%s',                                 '%s',                                 '%s'                                 );                     $wpdb->insert( $table, $data, $format);


search only pages if on page

i have a site made up of pages and posts. there are only a few pages and a ton of posts. how can i set the search box in my sidebars to search pages only if on a page, or search posts only if on my blog page? right now it mixes everything together on my search page. it would be even cooler if there was a way to add checkboxes under the search box to select posts or pages. thanks!


remove the 'page' URL parameter in previous/next posts link

I want to remove the "page" bit from the URL when I use the `previous_posts_link` and `next_posts_link`. Right now, it looks like: http://mywebsite.com/page/2 I want it to look like this: http://mywebsite.com/2 How can I do it? Thanks!


Updating WordPress Theme/Plugin POT file without losing line numbers consistency

This is a recurrent problem I have when building WordPress Theme or Plugin: each new feature added to the code breaks the i18n files consistency. POT/PO files store the line number of the translated string, so if I add a new ten- lines block of code to my Theme's functions file for instance, all translated strings' line numbers from this point will be wrong. Currently I'm stuck with generating a new POT file with makepot and using a diff tool to update all line numbers accordingly. This is a waste of time especially when dealing with large translation files and/or multiple POT files… Did anyone ever came up with a clever way to update language files line numbers without crippling the already translated texts? Thanks!


How to set twenty fourteen header image at 100% width?

if                function wpse_custom_header_setup() {     add_theme_support( 'custom-header', apply_filters( 'wpse_header_args', array(         'width'                  => 1460,         'height'                 => 220,     ) ) );     }     add_action( 'after_setup_theme', 'wpse_custom_header_setup' );      can help define the width of the header in px, how I can set up a header image at 100% to get something similar like http://braidingfreedom.com/?


Why are wordpress posts not hierarchical?

I've been using WordPress as a CMS for about 7 months now with the following core features:   * Navigation Tree: Wp_list_pages for easy navigation of pages   * Solr search engine: indexing posts only (because some pages are duplicated in the tree)   * Pages that embed posts. Just about every page contains an embedded post. The reason is so that I can reference a post in multiple places on the Tree Navigation without having to edit each page individually. Thus, my process for managing my CMS is to:   1. Create a post of new content   2. Select taxonomies (for use with Solr search filtering)   3. Publish post. Upon publishing, a page is automatically created with the embedded post with a parent of "Standby". This saves me some time.   4. Go to Standby to see my pending pages and organize in my tree hierarchy (via CMS Tree Page View). I will duplicate the page if I wish to have the embedded post featured in multiple places in the tree. Does my process meet my CMS needs? Yes. Does it effectively double my MySQL data? Yes. Is a page with an embedded post the best solution to creating an effective hierarchical CMS? I'm not sure. It would be nice to organize posts in a tree hierarchy for the convenience of site navigation on the front end, without having to create a page. It is also essential that when I edit the embedded post, all pages holding that post are updated. Is there a better way of creating a hierarchical tree and what is the reason behind posts not being hierarchical?


Is it possible to define a template for a custom post type within a plugin independent of the active theme?

I'm writing a plugin to manage data about open-source projects. I developed an object model and have successfully created all custom post types and taxonomies, as well as implemented the correct capabilities/roles using the `Members` plugin. The appropriate users can create, modify, and delete their own posts, and administrators can approve them, as well as modify and delete anyone's posts. My problem is, that I want to define the template for a single Project and for a list of Projects (single and archive, I believe - I've never worked with Wordpress at this level), but I do not want The Loop to rely on the current theme to render the page for a single Project or a list of Projects. If I am using the TwentyTen theme, I want it to use my plugin's template for those custom post types. If I am using the TwentyEleven theme, I still want it to use my plugin's template for those custom post types. I want this to obey the "it just works" paradigm, but right now users can't just drop the folder in the plugin directory - they have to add the appropriate files to their theme folder every time they switch themes. I've checked out the template hierarchy and I have the filenames correct, but they aren't used by Wordpress if they are in the plugin folder, or in plugin/templates folder. Thanks!


Unable to login + Redirect loop on mobile

When I try to login to my wordpress page, I'm stuck in the loginpage without any CSS. Filling in the correct logins doesn't get me logged in. I just get redirected to that same page: http://i61.tinypic.com/fm71ft.png I also have another problem. When I try to visit the website on a mobile phone, it's stuck in a redirection loop. I don't know to fix it :/ URL is: www.chiroharbalorifa.be Thanks in advance!


Display all posts in a page code for template

I have found some code to display all posts in a page but it's not exactly what I need. What I need to do is for example:
This is the Title

This is the content of the posts. It displays part of the content only.     User need to click the More! link below to view the whole post.
          More!      This code I found only displays the date and the title as a link. Here is the code:               <?php     $debut = 0; //The first article to be displayed     ?>     <?php while(have_posts()) : the_post(); ?>
<?php the_title(); ?>

     <?php     $myposts = get_posts('numberposts=-1&offset=$debut');     foreach($myposts as $post) :     ?>
<?php the_time('d/m/y') ?>: <a href="<?php the_permalink(); ?>"><?php the_title(); ?>
     <?php endforeach; ?>
     <?php endwhile; ?>


Custom post type pagination like "previous current/all next"

I have custom post type `works` with custom taxonomy `work_category` I want to build such pagination while viewing `single.php` **previous 2/25 next** [`link to previous post in custom tax`] [`current post number`]/[`all post number from custom tax`] [`next post in custom tax`] Currently i can't get `current post number`


Is there a simple way to have a new sidebar for each page?

I am the programmer on my small dev team, along with the content editor and designer. My colleagues want to be able to add a different sidebar to each new page they make without having to monkey with PHP code. Is there a plugin or some other way of allowing them to make a new widgets sidebar for new pages they create?


Using shortcodes to communicate my page design

I came across this page http://flare.bringthepixel.com/pages/services/ and on it there is this message: "The entire code of this sample page is available in the Shortcode Generator". Lets say i gave someone this theme and wanted to produce his/her own page look just like the one shown without inserting one shortcode after another.Can shortcodes be used to make one big page "template" such that with one insertion of shortcode,the design in the services page shall be inserted and the user shall only swap the dummy content for his/her own?.


Link to Portfolio page by id instead of name

I'm trying to make a dynamic button that goes to portfolio page (no matter what ID/name it has), it's currently like this:               $portfolio_page = get_option('theme_portfolio_page');     $portfolio_pid = get_page_by_title($portfolio_page);               <a href="<?php echo get_option ('theme_portfolio_page') ?>">Voltar      The problem is that it links based on the page name, and when it has space on the name it bugs... So I would need a code that links dynamically to the portfolio page by ID When I try to change to **get_page_by_id** FATAL ERROR: CALL TO UNDEFINED FUNCTION GET_PAGE_BY_ID() IN /HOME/DOMAIN/WWW/WP-CONTENT/THEMES/MYTHEME/PORTFOLIO-TEMPLATE.PHP ON LINE 46


Adding Custom Styles to the MCE dropdown toolbar

I am using the following code to add style drop downs the mce toolbar, I want to be able to add a h1 element with the drop down but my code isnt working, I have tried a couple of different ways but it doesnt work, I got this code form here               add_filter( 'mce_buttons_2', 'my_mce_buttons_2' );     function my_mce_buttons_2( $buttons ) {         array_unshift( $buttons, 'styleselect' );         return $buttons;     }     //mce custom classes     add_filter( 'tiny_mce_before_init', 'my_mce_before_init' );          function my_mce_before_init( $settings ) {              $style_formats = array(             array(                 'title' => 'Button',                 'selector' => 'h1',                 'classes' => 'button'             ),             array(                 'title' => 'h1',                 'block' => 'h1',                 'classes' => 'superHead',                 'wrapper' => true             ),             array(                 'title' => 'Bold Brown',                 'inline' => 'span',                 'styles' => array(                     'color' => '#481e07',                     'fontWeight' => 'bold'                 )             ),             array(                 'title' => 'Header',                 'inline' => 'span',                 'styles' => array(                     'font-size' => '24px'                 )             )         );              $settings['style_formats'] = json_encode( $style_formats );              return $settings;          }          //mse custome classes     add_action( 'admin_init', 'add_my_editor_style' );          function add_my_editor_style() {         add_editor_style();     }


Save data of select list after clicking save

I already have a meta box in the edit post that has a select list with custom taxonomies. But after i save the post the select list returns it value to none, **so i don't know how to save the selected value**. Can't solve this as i can't figure other codes that don't deal with this one. Here's my php that creates the metabox and the select list:               <?     function prfx_custom_meta() {     add_meta_box( 'prfx_meta', __( 'Reproductor 1', 'prfx-textdomain' ),     'prfx_meta_callback', 'post' );     }     add_action( 'add_meta_boxes', 'prfx_custom_meta' );          function prfx_meta_callback( $post ) {     wp_nonce_field( basename( __FILE__ ), 'prfx_nonce' );     $prfx_stored_meta = get_post_meta( $post->ID );     ?>          <p>     <label for="Netu" class="prfx-row-title"><?php _e( 'Netu', 'prfx-textdomain' )?></label>     <select name="Netu" id="Netu">     <option value="Ninguno" <?php if ( isset ( $prfx_stored_meta['Ninguno'] ) ) selected(        $prfx_stored_meta['Ninguno'][0], 'Ninguno' ); ?>><?php _e( 'Netu', 'prfx-textdomain' )?></option>';     <option value="Netu" <?php if ( isset ( $prfx_stored_meta['Netu-cast'] ) ) selected(        $prfx_stored_meta['Netu-cast'][0], 'Netu Castellano' ); ?>><?php _e( 'Netu      Castellano', 'prfx-textdomain' )?></option>';     <option value="Netu-vose" <?php if ( isset ( $prfx_stored_meta['Netu-vose'] ) ) selected(  $prfx_stored_meta['Netu-vose'][0], 'Netu Inglés Subtitulado' ); ?>><?php _e(      'Netu Inglés Subtitulado', 'prfx-textdomain' )?></option>';     <option value="Netu-latino" <?php if ( isset ( $prfx_stored_meta['Netu-latino'] ) )    selected( $prfx_stored_meta['Netu-latino'][0], 'Netu Latino' ); ?>><?php _e( 'Netu Latino', 'prfx-textdomain' )?></option>';     </select>     </p>      And here's the one that should save the value:                <?php }      function prfx_meta_save( $post_id ) {          // Checks save status      $is_autosave = wp_is_post_autosave( $post_id );     $is_revision = wp_is_post_revision( $post_id );     $is_valid_nonce = ( isset( $_POST[ 'prfx_nonce' ] ) && wp_verify_nonce( $_POST[          'prfx_nonce' ], basename( __FILE__ ) ) ) ? 'true' : 'false';          // Exits script depending on save status     if ( $is_autosave || $is_revision || !$is_valid_nonce ) {     return;     }          add_action( 'save_post', 'prfx_meta_save' );          if( isset( $_POST[ 'Netu' ] ) ) {     update_post_meta( $post_id, 'Netu', $_POST[ 'Netu' ] );     }          if( isset( $_POST[ 'Ninguno' ] ) ) {     update_post_meta( $post_id, 'Ninguno', $_POST[ 'Ninguno' ] );     }          if( isset( $_POST[ 'Netu-cast' ] ) ) {     update_post_meta( $post_id, 'Netu-cast', $_POST[ 'Netu-cast' ] );     }          if( isset( $_POST[ 'Netu-vose' ] ) ) {     update_post_meta( $post_id, 'Netu-vose', $_POST[ 'Netu-vose' ] );     }          if( isset( $_POST[ 'Netu-latino' ] ) ) {     update_post_meta( $post_id, 'Netu-latino', $_POST[ 'Netu-latino' ] );     }     }     ?>


All permalinks go to products page with WP E-Commerce plugin?

I realize that maybe this isn't the best place to ask this, but since getshopped.org (the makers of the plugin) don't seem to have any support form, AND since I am unable to access the forums I'm posting here... After installing WP E-Commerce to test how it works, I discovered that all links to blog posts and pages on my site go to the WP E-Commerce page. I've looked at the FAQ and nothing seems to fix this problem of all my links going to the wrong place now. Any help would be appreciated.


Modify Twenty Fourteen Home Page Content Limit & Add Read More Link

I've install the new Twenty Fourteen theme for WordPress. I don't know how add summary text of posts on my front page. All old tutorials like this does not work with new theme. Any suggestions on how to solve this


How to Change Author Posts URL

How can I display an authors archive by author id instead author slug like               http://example.com/author/author_slug/      to               http://example.com/author/123/


Add plugin form to front page... how?

Hello i know its very easy but i spend lots of time on google every where viewing just install and activate plugin... 1\. write shortcode of plugin on front page or post. 2\. As widget customise it on front page. So for that i have installed User Registration Aide plugin and getting fed off that how to show it on my front page or desire page, becouse in admin i am not getting any shortcode and this is also not in widget... So please show me the right direction... thanks


Check for template part, else filter content

In a plugin which brings its own post type to the table, I wish to handle `post_meta` by filtering `the_content` \- unless the user has provided their own `single-{post-type}.php` template. Should I run this within `the_content` filter? Or elsewhere?               if ( file_exists( get_stylesheet_directory() . '/single-event.php' ) ) {         include( get_stylesheet_directory() . '/single-event.php' );     } elseif ( file_exists( get_template_directory() . '/single-event.php' ) ) {         include( get_template_directory() . '/single-event.php' );     } else {         // filter time     }      If it's not in my `add_filter('the_content', 'event_filter_function', 10);` then I guess I'm wondering how else I will know at run-time whether this file exists. So is computationally expensive to run this filter and simply return $content unaltered if there is a template provided? Or is there a better way?


jaredatch metaboxes on video post formats

I'm trying to get a metabox to show up only when the video post formats is selected using jaredatch metaboxes https://github.com/jaredatch/Custom- Metaboxes-and-Fields-for-WordPress/wiki/Display-Options If I select post as post type the box is applied to all posts. I've tried combos with 'show on' but none seem to target video format.


Single.php Active Category Class

Currently by default (I believe) when you're on single.php, Wordpress doesn't add a "Active" class to the blog category you're viewing the single post in like it would for pages or if you're on the category archive. Archive also doesn't have this (if you list them). Is there a way to add an "Active" class to posts parent categories after you list them? I'm listing my Categories and Archives the standard way:

<a href="<?php echo get_permalink(15); ?>">Categories

                 <?php                     wp_list_categories(array(                         'title_li'  =>  '',                         'echo'      =>  1                     ));                      ?>

<a href="<?php echo get_permalink(15); ?>">Archives

                 <?php wp_get_archives('type=monthly&limit=12'); ?>

      Just to clarify; When you're on the category it will add the class `current- cat` to the list item, but when you're on one of the single posts it doesn't add any kind of class to the category to signify that the post belongs to it. This is the permalink structure I'm using (if it matters):               /blog/%year%/%monthnum%/%day%/%postname%/


how to show only specific category for a template

I have a custom template which should only show posts of specific categories. What do i need to change inside this code, to get this done?               if ( ! function_exists( 'attitude_theloop_for_template_blog_full_content_one' ) ) :     /**      * Fuction to show the content of page template full content display.      */     function attitude_theloop_for_template_blog_full_content_one() {         global $post;              global $wp_query, $paged;         if( get_query_var( 'paged' ) ) {             $paged = get_query_var( 'paged' );         }         elseif( get_query_var( 'page' ) ) {             $paged = get_query_var( 'page' );         }         else {             $paged = 1;         }         $blog_query = new WP_Query( array( 'post_type' => 'post', 'paged' => $paged, 'cat' => 1 ) );         $temp_query = $wp_query;         $wp_query = null;         $wp_query = $blog_query;               global $more;    // Declare global $more (before the loop).              if( $blog_query->have_posts() ) {             while( $blog_query->have_posts() ) {                 $blog_query->the_post();                      do_action( 'attitude_before_post' );     ?>         <section id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
                      <?php do_action( 'attitude_before_post_header' ); ?>
                         <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute();?>"><?php the_title(); ?>
                                       <?php do_action( 'attitude_after_post_header' ); ?>                      <?php do_action( 'attitude_before_post_content' ); ?>
                     <?php                         $more = 0;       // Set (inside the loop) to display content above the more tag.                              the_content( __( 'Read more', 'attitude' ) );                              wp_link_pages( array(                              'before'            => '

'.__( 'Pages:', 'attitude' ),                             'after'             => '
',                             'link_before'       => '',                             'link_after'        => '',                             'pagelink'          => '%',                             'echo'              => 1                     ) );                      ?>
                      <?php do_action( 'attitude_after_post_content' ); ?>                      <?php do_action( 'attitude_before_post_meta' ); ?>

                         <?php _e( 'By', 'attitude' ); ?> <a href="<?php echo get_author_posts_url( get_the_author_meta( 'ID' ) ); ?>"><?php the_author(); ?> |                         <a href="<?php the_permalink(); ?>" title="<?php echo esc_attr( get_the_time() ); ?>"><?php the_time( get_option( 'date_format' ) ); ?> |                         <?php if( has_category() ) { ?>                         <?php the_category(', '); ?> |                     <?php } ?>                          <?php if ( comments_open() ) { ?>                         <?php comments_popup_link( __( 'No Comments', 'attitude' ), __( '1 Comment', 'attitude' ), __( '% Comments', 'attitude' ), '', __( 'Comments Off', 'attitude' ) ); ?> |                     <?php } ?>

                      <?php do_action( 'attitude_after_post_meta' ); ?>

     <?php                 do_action( 'attitude_after_post' );                  }             if ( function_exists('wp_pagenavi' ) ) {                  wp_pagenavi();             }             else {                 if ( $wp_query->max_num_pages > 1 ) {                 ?>

<?php next_posts_link( __( '« Previous', 'attitude' ), $wp_query->max_num_pages ); ?>

<?php previous_posts_link( __( 'Next »', 'attitude' ), $wp_query->max_num_pages ); ?>

                     <?php                  }             }         }         else {             ?>
<?php _e( 'No Posts Found.', 'attitude' ); ?>
           <?php        }        $wp_query = $temp_query;             wp_reset_postdata();     }     endif;      this code is from the file content-extensions.php in the library/structure folder, im using wordpress 3.6.1 with attitude-free from theme-horse.


Change Post Status From Front End

I am using the code in a page below to let users delete their posts from the front in. I have wp-admin totally blocked off to site users. What i want to do is when they click the delete button the post actually goes into draft or pending mode so there is still a record of the post but the front end cant view it.                    <?php      if( 'POST' == $_SERVER['REQUEST_METHOD'] ) {      set_query_var( 'postid1', $_POST['postid'] );      wp_delete_post( get_query_var( 'postid1'), true ); }; ?>      <?php query_posts( array( 'author' => $current_user->ID,'post_status' =>  'publish' , 'post_type' => array(    'user_lists' )  ) ); ?>        <?php if ( !have_posts() ): ?>

        <?php _e( 'No Lists found.', 'lists' ); ?>

     <?php endif; ?>      <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
Your Lists

Date And Time

Delete

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

';         echo ''; the_time('F j, Y'); ?> at           <?php the_time('g:i a'); echo '';              echo '

'; ?>         <?php  change_post_status( the_ID, 'private'); ?>          <form class="delete-list" action="" method="post">           <input type="hidden" name="postid" value="<?php the_ID(); ?>" />           <input class="more-button" type="submit"  value="Delete" />         </form>         <?php  echo '

'; ?>          <?php endwhile; ?>         <?php wp_reset_query(); ?>

Date And Time

Delete


loading custom registration template

I read this tutorial, here the author names the template `custom-register.php` and puts it in the theme dir and doesn't explain about how it's loaded by WP, I did the same way but the file didn't loaded on request to the WP signup. What's the trick here?


Checkbox doesn't stay checked, conten

I'm using the morefields plugin to create textfields and checkboxes in the dashboard. For a test I have first created a checkbox on 'pages' if it was checked, the frontend showed the text 'TESTCONTENT', if it wasn't it was showing 'GEEN CONTENT'. It worked, so the code I used is working also. Now I want to show an extra div in a custom-post-type loop containing a 'new' stamp , so I created a checkbox on the `projecten` (the name of my `CPT`.) I gave this the value and field-key: `'newproject'`. Now when I want to check my checkbox, I go to a project and turn the checkbox on, but when I update the project and look again, the checkbox turned itself off. I can't figure it out, I thought maybe it is because I put a loop in a loop but I don't think it had something to do with the checkbox turning off. This is my code of the whole loop (so, the loop in the loop)               <?php if (have_posts()) : while (have_posts()) : the_post(); //opening 1st loop?>

                             <?php $newproject = get_post_meta( $post->ID, 'newproject', true ); //checkbox?>                                 <?php if($newproject) { //if checkbox is checked?>
Nieuw

<?php meta('project-text'); ?>
                                 <?php } else { //if checkbox isn't checked?>
<?php meta('project-text'); ?>
                                 <?php } ?>                                  <?php $featured = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), "Full"); ?>                             <img src="<?php bloginfo('template_url');?>/thumb.php?src=<?php echo $featured[0]; ?>&w=300&h=200&zc=1&q=100&" width="300" height="200" data-thumb="<?php bloginfo('template_url');?>/thumb.php?src=<?php echo $featured[0]; ?>&w=300&h=200&zc=1&q=100&" alt="<?php the_title(); ?>" />

<?php the_title(); ?>

                             <?php the_content(); ?>
                         <a href="<?php the_permalink(); ?>">
<?php meta('project-button'); ?>

                 <?php endwhile; endif; wp_reset_query(); ?>      **EDIT** The loop is working, I just refreshed the page and one of the checkboxed was checked, with the effect I want. Now, if I want to check one, they turn their- self off automatically again.


How to remove certain feed from my dashboard in WP admin

E.g. From some plugin I have, a RSS feed called WP marketing feed is generated. How to remove just this one feed from my WP admin? I want others to remain as they are.


how to use force_filtered_html_on_import in add_filter?

This is my situation. I have two plugins, one plugin will read a remote XML file and downloads content then it calls a function on another plugin to do the actual importing of posts to the WordPress database. Now here is the problem, the second problem inserts posts using wp_insert_post method and this is a multisite implementation. As a result, it strips div ids inside the post_content for example:               <div id="this_is_example">      Would become:               <div>      Someone suggests me to use force_filtered_html_on_import filters like this:               add_filter( 'force_filtered_html_on_import', '__return_false', 999 );      This will disable the filtering of HTML during import and will preserved the div ids inside the post_content. I have tried adding this filter on the first plugin but it didn't work. I have a restriction to add this filter to the first plugin as the second plugin is beyond my control. How to make this work by only adding this filter on the first plugin that do the import? This filter is not so documented by WordPress. I would appreciate any help on this one. Thanks.


3 blogs same installation, without WP MU

I've to create 3 blogs (different **DOMAINS** ) on the same wordpress installation (I **cannot use WP MU** , unfortunately) so I came out with the idea that I could use categories, instead, so... every blog has its own category (categories would be used only for that.) (eg: **blog1.com = blog1** ) and urls must go like this: **blog1.com/1891/23/some-title/** **blog2.com/1892/25/some-other-title/** Is there some other way to do it? a plugin, maybe?! Because if I do it this way, I've to redirect a lot of stuff.. have to create a custom homepages etc. could it be done with htaccess or needs to be php? I don't even know if it is possible, and how good will it work... What you think? I need your thoughts on this. thank you.


Do I have to set parent when set post term?

When save a term which is a child term, if I don't provide specific parent id, will WP make this term's parent 0 ?


plugin shortcodes not working on custom theme- unsure how to fix

Live site. I've got a custom theme that is giving me slight issues with shortcodes- they don't work. When I switched back to the default theme, the shortcodes worked fine. What do I need to look for in my custom theme to be the culprit? If it matters, the shortcodes are for Contact Form 7 and Bookings plugins. contact.php               <?php     /*     Template Name: Contact     */     ?>          <?php get_header(); ?>
Tell us, what's on your mind? Questions, comments, hellos- share them below.
          <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>     <?php endwhile; else: ?>
<?php _e('Sorry, no posts matched your criteria.'); ?>
     <?php endif; ?>                     <?php get_footer(); ?>      Any and all help is greatly appreciated.


is there a way I can add or remove some plugin options?

I don't know if my question is clear.![this image might make it clear.](http://i.stack.imgur.com/rheTQ.png) I want to add and remove some options in the circled section of the image. thanks.


Wordpress template css does not load over http but does over https

My Wordpress template "The7" from themeforest.com css does not load over http but does over https. No caching or any other optimization is enabled in the server nor any related plugins are active. I have managed to make it work once but have no idea what I did to fix it. Link: http://islandfactory.eu


**What experiences have you had withMarketPress vs. other WP ecommerce solutions?** I found a client that wants to use it and I never worked with it before. How does it compare with WooCommerce or WP e-Commerce? Or does anyone know of a good and recent comparison of WordPress ecommerce solutions? ...everything I find on this is either shallow or old...


How to display an error message to the user in the Theme Customizer?

I am developing my own Theme Customizer Control, and I was wondering if it was possible to display an error message to the user. I use the `WP_Customize_Image_Control`, and I would like to prevent user from choosing an image that does not fit into the right dimensions. I do not see anything in the source code of this class related to an error message display.


Query that loads a custom type AND posts whose ids are not inside those custom types custom fields

On my news website I have posts and another custom type called "aggregato". This type has 10 custom fields, "link01", "link02"... "link10". Both posts and aggregato has a meta key, called "home", that is used to say WP to put the post on front page. I want to make a query for the front page that loads the 12 latest post OR aggregato that has a `home>0`. I also want to exclude the posts that are linked inside the aggregato. If this was a simple SQL query I'd create a clause that looked something like this:               WHERE post.home>0     AND aggregato.home>0     AND post.id<>aggregato.link01     ...     AND post.id<>aggregato.link10     LIMIT 12      A workaround could be a double query. The first of the aggregato type and then a second for the post type. Still, I'd rather find the right WP_Query instead.


Generated media have incorrect aspect ratio

Uploaded an image via standard 'add new' dialog to the WordPress Media library. Here were the original Media Settings:   * Thumbnail - 150x150   * Medium - 300x300   * Large - 1024x1024 I uploaded a 650x144 image. Resulting generated image sizes:   * 150x144.jpg   * 300x66.jpg   * 336x144.jpg Only the medium image has the correct ratio. The other two images are basically a crop of the middle of the original image. I've tried deselecting the 'crop thumbnail' box next to the thumbnail. I've tried changing the height to 0. So far nothing has worked. What am I missing?


Is it possible to make tag archive page specific to Custom Post Type?

I want to create a tag archive page (or template) specific for some custom post type(CPT). I am little new to PHP and Wordpress, by the way. In my environment, I have CPT `portfolio` and custom taxonomy `portfolio_category`. I could make default tag archive page using the template `tag.php` that shows posts with specific tag from all post types. Here's what I did to my `functions.php`.               add_filter('pre_get_posts', 'query_post_type');     function query_post_type($query) {     if( is_category() || is_tag() ) {         $post_type = get_query_var('post_type');         if($post_type)             $post_type = $post_type;         else             $post_type = array('post','portfolio','nav_menu_item');             $query->set('post_type',$post_type);             return $query;     }     }      What I want to do: For example, when user clicks a tag `photo` in a single page in CPT(`portfolio`), I want to serve the page(or template) only shows posts from CPT(`portfolio`) not from all post types. I just played around with `tag.php` a bit, but no luck so far... Here's what I thought would work, but not...               <?php     $tag = get_query_var('tag');          $args = array(         'post_type' => 'portfolio',         'post_status' => 'publish',         'posts_per_page' => 3,         'caller_ get_ posts' => -1, // remove sticky post         'paged' => $paged,         'tag' => $tag     );     $my_query = null;     $my_query = new WP_Query($args);     if( $my_query->have_posts() ) :              if ( $my_query->have_posts() ) while ( $my_query->have_posts() ) :  $my_query->the_post();      ?>     <a href="<?php echo get_permalink(get_the_ID()); ?>"><?php the_title(); ?>     <?php endwhile; // end of the loop.         endif;     wp_reset_query();     ?>      This will end up with showing all posts from all post types. Can anyone help me how to do it? If this question is redundant, let me know. Thanks. **My CPT and taxonomy:**               // CPT for portfolio     add_action('init', 'regist_cpt');     function regist_cpt() {         register_post_type('portfolio', array(             'label' => 'Portfolio',             'description' => 'My portfolio',             'public' => true,             'show_ui' => true,             'show_in_menu' => true,             'capability_type' => 'post',             'map_meta_cap' => true,             'hierarchical' => true,             'taxonomies' => array('post_tag'),             'rewrite' => array('slug' => 'portfolio', 'with_front' => 1),             'query_var' => true,             'has_archive' => true,             'menu_position' => '5',             'supports' => array('title','editor','excerpt','trackbacks','custom-fields','comments','revisions','thumbnail','author','page-attributes','post-formats'),             'labels' => array (                 'name' => 'Portfolio list',                 'singular_name' => 'Portfolio',                 'menu_name' => 'Portfolio',                 'add_new' => 'Add new',                 'add_new_item' => 'Add new item',                 'edit' => 'Edit',                 'edit_item' => 'Edit item',                 'new_item' => 'New item',                 'view' => 'View',                 'view_item' => 'View item',                 'search_items' => 'Search item',                 'not_found' => 'Not found...',                 'not_found_in_trash' => 'Not found in trash',                 'parent' => 'Parent',             )         ));     }          // Custom Taxo for portfolio     add_action('init', 'regist_tax');     function regist_tax() {         register_taxonomy(             'portfolio_category',             'portfolio',             array( 'hierarchical' => true,                 'label' => 'Portfolio Category',                 'show_ui' => true,                 'query_var' => true,                 'rewrite' => array( 'slug' => 'portfolio' ),                 'show_admin_column' => true,                 'labels' => array (                     'search_items' => 'caetgory',                     'popular_items' => 'popular',                     'all_items' => 'all',                     'parent_item' => '',                     'parent_item_colon' => '',                     'edit_item' => '',                     'update_item' => '',                     'add_new_item' => 'Add new item',                     'new_item_name' => 'New item name',                     'separate_items_with_commas' => '',                     'add_or_remove_items' => '',                     'choose_from_most_used' => '',                 )             )         );      }


Getting categories from DataBase & WP Favorite Post

I am trying to create a shortcode that pull the most saved posts (using WP Favorite Post) and displaying them by YEAR, MONTH or CATEGORY. So far I have been able to get the year and month working but I get SQL errors when I try the Category. This is how the shortcodes should work               [favorite_in_time post_type='post' number='3' year='2014'] // Most saved in 2014          [favorite_in_time post_type='post' number='3' month='7'] // Most saved in July          [favorite_in_time post_type='post' number='3' category='2'] // Most saved in category ID 2      And this is the PHP I'm stuck with               function list_most_favorite_in_time ( $atts, $content = null ) {              $thismonth = date('n');         // get our variable from $atts         extract(shortcode_atts(array(             'number'        => '3',             'post_type'     => 'post',             'year'          => '',             'monthnum'      => $thismonth,             'category'      => '',             'show_count'    => '1',         ), $atts));              global $wpdb;              $request  = " SELECT * FROM $wpdb->posts, $wpdb->postmeta ";         $request .= " WHERE $wpdb->posts.ID = $wpdb->postmeta.post_id ";         // Get Year         if ($year != '') {             $request .= " AND YEAR(post_date) = '$year' ";         }         // Get Month         if ($monthnum != '') {             $request .= " AND MONTH(post_date) = '$monthnum' ";         }         $request .= " AND post_status='publish' AND post_type='$post_type' AND meta_key='".WPFP_META_KEY."' ";         $request .= " ORDER BY $wpdb->postmeta.meta_value > 0 DESC LIMIT $number ";         $posts = $wpdb->get_results($request);              $return = '';         $return .= '
';              foreach ($posts as $item) {                  $post_title = stripslashes($item->post_title);             $permalink = get_permalink($item->ID);             $post_count = $item->meta_value;                  $return .= '
' . $post_title . ' ';             if ( $show_count == '1') {                 $return .= '' . $post_count . ' ';             }             $return .= get_the_post_thumbnail($item->ID, 'thumbnail');             $return .= '
';              }              $return .= '
';              return $return;          }     add_shortcode('favorite_in_time','list_most_favorite_in_time');      Any help would be great! thanks


Hierarchical permalink structure for posts showing categories and sub-categories

I'm having a lot of trouble finding an aswer to this. This is what happens to my permalink structure currently:   * When I open the page, filtering all posts for a category, the url is: `myblog.com/category/`   * When I open the page filtering all posts for a sub-category the url is: `myblog.com/parent-category/child-category` Both are OK! But... When I open the page for a blog post listed in a sub-category the url is: `myblog.com/parent-category/postname` I need the URL to be: `myblog.com/parent-category/child-category/postname` But I don't know how to add the proper rewrite rule for this! Any ideas? My current Permalink structure is `/%category%/%postname%/`


WordPress multi-site: How do I create the home page, the root URL?

I have a WordPress installation running since ages ago at mydomain.com. It's mostly administered by someone else, so I haven't really had to understand the inner workings of WordPress—I can create and edit content, but I don't mess around in the code. Today I created a new site using the multi-site features, located at mydomain.com/project/. Everything went well—the site was created, I could set up the theme etc, but when I try to create the home page (i.e. simply mydomain.com/project), I can't get the URL right. No matter how I try, I'm not allowed to create a page with an empty slug, so all pages I create get something like mydomain.com/project/some-slug instead. How do I create a page with the URL mydomain.com/project in this site?


Point get_header() to different plugin

I'm trying to filter the get_header function on an specific page template to use a custom header located on my plugin folder. So instead of outputting the theme header, it'd output a custom header from my plugin. Is this doable?


Hide gravity forms

I have gravity forms set up on my site and I am wanting to hide/show a form based on whether or not the user has posted an entry into the form/database. If they have made an entry, then I want to hide it and display some simple text. I see that gravity forms allow you to limit number of entries but this is not quite what I am after. I'm guessing I would have to query the database but I'm not really sure the best way to write it. Would I have to use something like get_posts and check if the author has an entry? Would this be the best way to do it?


How to Add Custom Fields to a Custom Post Type?

Ok, so I have registered a few custom post types and a few taxonomies. Now, for the life of me, I cannot figure out the code I need to add a Custom Field to my Custom Post Type. I need a drop down and a single line text area. But I also need to have separate fields for post types. So, say post type one has 3 fields and post type 2 has 4 fields but the fields are different. Any tips would help I have looked at the codex and found something but cannot make sense of what I need to add to my `functions.php` file


CNAME vs A Record for WWW - with 301 Redirects

I am using a 301 redirect plugin: Quick Page/Post Redirect Plugin and my site's URL is `http://example.com` <\-- notice no `www`. This works great for the following scenario: ### User types: _example.com/campaign_ My redirect of `/campaign/ => http://example.com/longer-campaign-page-slug` works. Awesome. However, this next scenario does not work: ### User types: _www.example.com/campaign_ WordPress either 404s or tries to redirect to the most closely-named post (this is default behavior of WordPress as far as I can tell). Example, user lands at `http://example.com/campaign-from-last-month` because it is similarly named. I tried adding this to `.htaccess` but it did nothing:               RewriteBase /     RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]     RewriteRule ^(.*)$ http://%1/$1 [R=301,L]      Keep in mind, regular requests to actual pages work. For example: `http://www.example.com/super/awesome/slug/path` will successfully land to `http://example.com/super/awesome/slug/path`. The **www** record is a CNAME to the **A** record. Would having both of these be their own **A** record (to same IP) improve the situation? Or is there another solution I'm missing?


Set $options reference

I am starting up in theme development and i have searched on codex on the topic of setting theme options.This is is what i am talking about,               $options = array (          array( "name" => $themename." Options",         "type" => "title"),               array( "name" => "General",         "type" => "section"),     array( "type" => "open"),          array( "name" => "Colour Scheme",         "desc" => "Select the colour scheme for the theme",         "id" => $shortname."_color_scheme",         "type" => "select",         "options" => array("blue", "red", "green"),         "std" => "blue"),          array( "name" => "Logo URL",         "desc" => "Enter the link to your logo image",         "id" => $shortname."_logo",         "type" => "text",         "std" => ""),               array( "name" => "Custom CSS",         "desc" => "Want to add any custom CSS code? Put in here, and the rest is taken care of. This overrides any other stylesheets. eg: a.button{color:green}",         "id" => $shortname."_custom_css",         "type" => "textarea",         "std" => ""),                      array( "name" => "Feedburner URL",         "desc" => "Feedburner is a Google service that takes care of your RSS feed. Paste your Feedburner URL here to let readers see it in your website",         "id" => $shortname."_feedburner",         "type" => "text",         "std" => get_bloginfo('rss2_url')),               array( "type" => "close")          );      I took this $options from a tutorial on theme options i am following.Is there an official reference on the topic?.I have looked hard at codex and nothing so far.


Change <title> of each paginated page

> **Possible Duplicate:**   >  Add Page number to Meta Description in Wordpress SEO by Yoast I just had an SEO specialist do an audit on our site and one of the suggestions was to change each paginated page `<title>` tag because we could be penalized for duplicate content. I use SEO Ultimate and while there is a title rewriter, there doesn't appear to be a way to change titles based on pagination for individual pages. Any suggestions?


How to assign default taxonomy to pages on 'save_post'?

I try to assign custom taxonomies to a **_page_** when newly added by the "publish" button. This is the function:               function set_default_object_terms( $id, $post ) {     if ( 'publish' === $post->post_status ) {              log_me ('From inside function: '.__FUNCTION__.', while I pressed the "publish" button. Post-ID: '.$id);              $taxonomy_ar = get_terms( 'property-features', '' );              foreach ($taxonomy_ar as $taxonomy_term) {                       log_me ('Inside the function: '.__FUNCTION__.' and inside the "foreach"-loop for the ID: '.$id.' and Term: '. $taxonomy_term->name . ' and Post-ID :'. $post->ID);             wp_set_object_terms( $post->ID, $taxonomy_ar, $taxonomy_term->name, true );           }     }}      and here is the hook:               add_action( 'save_post', 'set_default_object_terms', 100, 2 );      In the logfile which i added to figure out if i find all my values, all my custom taxonomies get found:               [13-May-12 16:28] be in function while "publish" is pressed with this id: **64**     [13-May-12 16:28] In the "foreach" with id: 64 and Term: **Kitchen** and Post-ID :**64**     [13-May-12 16:28] In the "foreach" with id: 64 and Term: **Stove** and Post-ID :**64**     [13-May-12 16:28] In the "foreach" with id: 64 and Term: **Pets ok** and Post-ID :**64**      But it does not assign it. Does somebody know where the trick is?


add function to thematic hooks

i am newbie with php , i need help to create function to add it in thematic theme content area from this code ?               $term_slug = get_query_var( 'term' );     $taxonomyName = get_query_var( 'taxonomy' );     $current_term = get_term_by( 'slug', $term_slug, $taxonomyName );     $args = array( 'child_of' => $current_term->term_id, 'hide_empty'=>false);     $terms = get_terms( 'tagportifolio', $args);     $assoc = taxonomy_image_plugin_get_associations();          if (!empty($terms)):      <?php foreach( $terms as $child ): ?>     <?php  if(array_key_exists( $child->term_taxonomy_id, $assoc )){echo wp_get_attachment_image( $assoc[$child->term_taxonomy_id], array(), false, 'thumbnail');                                                             }                                                          ?>     <a href="<?php echo get_term_link( $child->name, $taxonomyName );?>"><?php echo $child->name; ?>
     <?php endforeach; ?>     <?php else: ?>      any help please ?


How can I apply a WP filter on specific plugin version

I have the plugins list in `'wp-admin/plugins.php'` page. For each plugin there is some meta info extracted by WP from each plugin file:                /*      * Plugin Name: somename      * Version: 1.2.3       */       I want to filter the version of a plugin, to show it in the plugins list, but not to modify the plugin file, just filter the version value. **Update:**               <?php     /*      * Plugin Name: aTestPlugin      * Version: old.version      * Description: This plugin is just for testing purpose.      * Plugin URI: http://wordpress.org/extend/plugins/atestplugin/      * Author: mario      * Author URI: http://www.atestplugin.example/      */          function atestplugin_plugin_row_meta($meta, $file, $data, $status) {          // do some filtering ...         if ( $data['Name'] == 'aTestPlugin' )             $meta[0] = 'new.version';              return $meta;     }     add_filter('plugin_row_meta', 'atestplugin_plugin_row_meta', 10, 4 );


Change default comments form title

> **Possible Duplicate:**   >  Change comments form title on a page by page basis I'm looking to change the comments form title (my theme defaults this to "Leave a Comment" or "Leave a reply to"). I thought perhaps I could add a hook to comment_form_defaults but my snippet below isn't working... any thoughts?                   <?php      add_filter('comment_form_defaults', 'askQuestion');          function askQuestion($defaults) {       $defaults['title_reply'] = 'Ask a Question';       $defaults['title_reply_to'] = 'Your text %s';       return $defaults;     }     ?>      This is being added to the HTML editor of the page editor within wordpress. We are using the ExecPHP plugin to compile code within posts/pages. We are looking for a way to do this on just this page, not every comment form on our blog.


Can I style single post that are in multiple catergories?

I have a regular wordpress site and I am trying to make a mobile version of the same site. For the blog section, I have put all of the posts in two categories: blog and mobile. The posts in "blog" show up fine on the regular site. Now I want those same posts to show up on the mobile site, but they need to be styled different to fit in the mobile world. My initial thought was just to put a post in both categories, but I've now realized that I can't just stylize the templates for both categories because since the posts are in two categories, wordpress (or single.php) doesn't know which category I want to have displayed. Which leads me to my questions: 1\. Is there a way to do what I have described above? It seems that single.php would have to know where the link was coming from in order to figure out which template to use.   1. Is there a better way to do what I'm trying to do? Basically, when a post is clicked on from the "category/blog" page, it should look one way and when it is clicked on from the "category/mobile" page, it should look different. I have been searching for days and I've found some posts and forums that deal with this, but no one seems to have an answer. Some posts have mentioned that there is a way to capture the current page url and then force single.php to display a certain template based on the link it comes from, however no one actually describes how it is done. The closest thing to what I'm trying to do seems to be discussed here but I don't understand what was done and I can't get it to work for me. I have posted in that forum, but no one has responded. This post here also seems to be trying to do something similar, but I don't understand how it works. The only way I can think to make this work is to have the author (who is not me) double post their post to two different categories, but that would become a pain. I've tried my best to articulate what I'm trying to do. If I'm not being clear, please let me know and I'll try to clarify. I'm hoping someone can help me either figure this out or show me a better way to do it. Thanks in advance.


how to get page id of a page using page slug

Im pretty new to wordpress and I was wondering if I could get a `page id` with it's `slug`. Is it possible please let me know.


Howto use WP built in Thickbox for images?

I've been searching for a better way to utilize the built in Thickbox function for images. I've been using my method for a few months, but I don't think it's the best way to do it. Here is the code I've been using (I don't remember where I found the code or I'd link to the article):               <?php     if (!is_admin()){     /*     add a word found in your domain name     */     $mydomain = ".com";     /*     The css selector     .entry-content a img      */     $myselector = "p a img";     wp_enqueue_style('thickbox'); //include thickbox .css     wp_enqueue_script('jquery');  //include jQuery     wp_enqueue_script('thickbox'); //include Thickbox jQuery plugin         // Function that will write js         function thickbox_js(){             global $mydomain, $myselector;             ?>             <script type='text/javascript'>              var tb_closeImage = "<?php bloginfo('wpurl'); ?>/wp-includes/js/thickbox/tb-close.png";              var tb_pathToImage = "<?php bloginfo('wpurl'); ?>/wp-includes/js/thickbox/loadingAnimation.gif";              jQuery(document).ready(function() {                  jQuery("<?php echo $myselector; ?>").parent("a[href*=<?php echo $mydomain; ?>]").addClass("thickbox");              });             </script>         <?php         }     add_action('wp_footer', 'thickbox_js'); // use wp_footer hook to write our generated javascript into page footer.     }     ?>      Any suggestions would be appreciated. I've tried several different methods listed in tutorials, but none have worked. Thanks... **To be more specific, this is the part in question:**               <?php bloginfo('wpurl'); ?>      **What I'm using now:**               <?php         function add_themescript(){          if(!is_admin()){          wp_enqueue_script('thickbox',null,array('jquery'));          wp_enqueue_style('thickbox.css', '/'.WPINC.'/js/thickbox/thickbox.css', null, '1.0');          }     }      add_action('init','add_themescript');          define("IMAGE_FILETYPE", "(bmp|gif|jpeg|jpg|png)", true);     function wp_thickbox($string) {     $pattern = '/(<a(.*?)href="([^"]*.)'.IMAGE_FILETYPE.'"(.*?)><img)/ie';     $replacement = 'stripslashes(strstr("\2\5","rel=") ? "\1" : "<a\2href=\"\3\4\"\5 class=\"thickbox\"><img")';       return preg_replace($pattern, $replacement, $string);     }          function wp_thickbox_rel( $attachment_link ) {     $attachment_link = str_replace( 'a href' , 'a rel="thickbox-gallery" class="thickbox" href' , $attachment_link );       return $attachment_link;     }     add_filter('the_content', 'wp_thickbox');     add_filter('wp_get_attachment_link' , 'wp_thickbox_rel');     ?>      I thinks that's a little better, but I'm still not sure it's the optimal way. Next I need to learn how to add navigation to the ThickBox pop-up images.


Custom menu deletes itself

I've set up a menu on one of my sites. The menu has ~30 items. Everything is fine, but at some point the menu crops itself and displays only the first 12 item. Does anyone have an idea why this is happening and how to tackle this issue?


Having admin on different host breaks attached images

Sometimes it's nice to have admin on a different host (admin.mysite.com) then the actual site (www.mysite.com). If admin.mysite.com is not publicly accessible, then images attached to posts on admin.mysite.com will not be accessible on www.mysite.com since the url to the attached image is absolute and contains the domain (admin.mysite.com). Is there any way to fix this? The nicest way would be if the url to an attached media would be relative and not absolute.


Jetpack Upgrade fails with WP CLI

Been trying to upgrade Jetpack from the admin for a few times on my site on a shared package with my hosted Dreamhost. It failed too often. I emailed on issues upgrading before and they suggested I use WP CLI so I did. But now I got this error:               wp plugin update jetpack     Downloading update from https://downloads.wordpress.org/plugin/jetpack.2.9.3.zip...     Unpacking the update...     Installing the latest version...     Removing the old version of the plugin...     Warning: Could not remove the old plugin.     Plugin update failed.      Sounded like there could perhaps be a permission issue even though I never had this before. So I checked permissions for the plugins folder I have:               drwxrwxr-x 10 me pgxxxxxx 4096 Apr 10 17:53 plugins      which is OK. But when I checked the plugin itself I saw that the plugin now has root as owner.               drwxrwxr-x 7 root    root       4096 Apr  7 19:38 jetpack      So that is a permission issue as my user is not root and sudo is not possible on shared servers with Dreamhost. Does WP CLI do this conversion to root on upgrades? Is there a way to make sure it does not change the user and group during an upgrade? Is there perhaps also a verbose option to get a more specific error message? the `--debug` option did not help so I guess that is for php errors only.


Filter post_meta for custom post types in Genesis 2.0

Working with Genesis 2.0: I have various Custom Post types declared, and I want to display as post meta information: \- in normal post: "filed under: category1, category2..." \- in the custom post type: "filed under: term1, term2..." The code copied below, works perfect for normal posts, but in custom posts it repeats two times the "Filed under:", the first one is empty, and the second one with the terms.               add_filter( 'genesis_post_meta', 'post_meta_filter' );     function post_meta_filter($post_meta) {         if ( !is_page() ) {             $post_meta = '  [post_categories before="Filed Under: "]                             [post_tags before="Tagged: "]                             [post_terms taxonomy="agenda" before="Filed under: "]             ';         return $post_meta;             }     }      How could I get only the second "Filed under" for custom post types? Any conditional order to specify that if categories is empty, don't show its field? Thank you!


Rewrite URL - how to do a SEO-friendly Unicode custom URL?

![SEO vs. Unicode](http://i.stack.imgur.com/rdHSN.png) After a major load of 404 with some category and tag URL, I questioned on StackOverflow about my WordPress blog. My blog is in Unicode Bānglā. After a nice anatomy on the fact in Facebook1 with some CodeGeeks, we came to a solution for both 404 on Unicode characters and SEO for Unicode sites. **THE IDEA**   Mr. Sarim Khan ( _the Gittu_ ) suggested a nice solution for a URL:   * **For category:** `http://www.example.com/category/astronomy/জ্যোতির্বিজ্ঞান`     * **For posts:** `http://www.example.com/%postid%/আমার-পোস্টটি-যে-বিষয়ে` For this case the article will browse with the preceding category `/astronomy`, and will work for English SEO too. And the rest of the section `/bānglā-slug` would work for Bānglā SEO, and with this method the 404 can be minimized to a great extent. But for a nice URL with Bānglā contents, I can manage my post and page URL, when I'm writing my page or post. But for Bānglā tags, and categories, how can I achieve such a modified URL? How can I put a Bānglā and English tag/category (taxonomy) at a time? **REAL QUESTION**   Currently I'm following `http://domain/%postname%`. How can I rewrite my URL, so that I can achieve such a benefit of lesser 404 for Unicode URL, and also doesn't get down in SEO chase. Desired URL is:   `http://domain/%english-slug%/%bangla-slug%` And of course: _Is that really possible?_ 1\. Facebook thread image: I'm afraid, most of the discussion was in Bānglā.


Display Comment Form on dedicated Page for each post

I have the following requirement to complete and i didn't figure out how to do it. Inside a post, for each post, to call comment form on a dedicated page, in dedicated page the user post a comment and then is redirected to the initial post on submit. in single.php i need to call comments_template() but to extract only the comments results without comment_form() then when a user wants to post something, calls a page (comment_page) where comment_form() is included, the comment_form extracts from session postID and other parameters which allows that a comment is right inserted into the specific post So far i manage to insert the comment form into a modal window(JS) but is not a friendly option. Thanx


can't reset get_posts

I have three loops in my theme that I want to use to get menu items for a lunch, dinner and wine list menu. The first loop worked fine but when I added the second one, the system broke. I did some searching here and they all say not to use $post. So I didn't but I still can't get it to work. I tried adding wp_reset_postdata as seen in the codex and decided to try wp_reset_query() for giggles after doing some searching here but it's still not working. I have been trying to change the variable names but still no joy.                $lunchargs = array(             'posts_per_page' => 5,             'category'       => 'lunch',             'post_status'    => 'publish',             'order'          => 'ASC',        );     ?>      $lunchposts = get_posts($lunchargs);         foreach( $lunchposts as $post) : setup_postdata( $post );  ?>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?>
         <?php endforeach;       wp_reset_postdata(); wp_reset_query()?>       So I repeat the code above three times changing the varaibles in all three loops like so               foreach( $dinnerpost as $post) : setup_postdata( $post );          foreach( $winelist as $post) : setup_postdata( $post );      I also found on here that some say not to use the category slug in the $args but I need to use the slug because I am not sure what the ID of the category will be in the end.


How to Order Posts by Custom Fields?

Can someone tell me why this is not working:               $args = array(         'cat' => '2,39,30',         'orderby' => 'title',          'order' => 'ASC',         'orderby' => 'meta_value_num',           'meta_key' => 'album_rating',           'order' => 'DESC'     );          $the_query = new WP_Query( $args );      I would like to order the posts according to their rating (Its working) AND alphabetically (Not working) Thanks


How to access options of Redux framework in front end

I'm creating a wordpress theme in which I'm using the Redux Framework for creating the theme's options page. Now I believe everything is well set up but I'm having trouble in getting the values changed by Redux in my front end. For example I checked one of the checkbox in the settings panel had this attribute: name="redux_demo[10]", so in my front end I did this:                   <?php          if(get_option('redux_demo[10]')) { ?>
Text
                <?php          }?>      But Text is not showing whether I save it as checked or unchecked. I also tried the following but it's also not working:                   <?php          if(get_option('redux_demo[10]') === 1) { ?>
Text
                <?php          }?>      I searched a lot in the docs and also on the internet but I can't find any tutorial that shows how to actually retrieve data saved by redux. Please let me know if you have any idea about this. Thank you very much.


Custom Div with links on Admin Bar

I'm trying to add an area on the admin bar that will display user Profile Image, User Name, User Email, User role, and links to Edit Profile and signout. The way in which I would like it to display is Steve Jackson - stevejack@yahoo.com Author Edit Profile <<< "Link" Signout <<< "Link" With the user image to the left of the user info Some far I have gotten the secondary div area in the admin bar to show without a dropdown menu and the hack the admin-bar.php file to display User Image, Name and email with this function               function wp_admin_bar_my_account_item( $wp_admin_bar ) {     $user_id      = get_current_user_id();     $current_user = wp_get_current_user();     $profile_url  = get_edit_profile_url( $user_id );          if ( ! $user_id )         return;          $user_info  = get_avatar( $user_id, 64 );     $user_info .= "{$current_user->display_name}";          if ( $current_user->display_name !== $current_user->user_email )         $user_info .= " - {$current_user->user_email}";               $wp_admin_bar->add_menu( array(         'id'        => 'my-account',         'parent'    => 'top-secondary',         'title'     => $user_info,         'meta'      => array(             'class'     => $class,             'title'     => __('My Account'),         ),     ) );     }


Plugin can't be activated

I'm developing a WordPress plugin, but the last changes caused the plugin to stop working. It tells me that I can't activate the plugin because it caused a fatal error. On localhost all is working fine, but after sending to the server, on activation it displays the following: > Can't use function return value in write context in > /data/web/virtuals/72282/virtual/www/wp-content/plugins/wp- > songbook/inc/wpsongs-shortcs.php on line 83 I really don't understand the context of this message, because the code of this line is:               $ytlink=(isset(get_post_meta(get_the_ID(),'songbook_video_link')))?get_post_meta(get_the_ID(),'songbook_video_link'):false;      Can anyone tell me what's happened?


How to display only one category in a custom post type?

I have a custom post type called 'portcat' and I want to display the results of only one portcat category ('games' - which has an ID of '3') on my page. The below code displays all of the categories and I'm not sure what I need to add to make it display only the 'games' category?
<?php echo the_title(); ?>

              <?php echo $firstCat[0]->cat_name; ?>

              <?php         $temp = $wp_query;         $wp_query = null;         $wp_query = new WP_Query();         $args = array(         'post_type' => 'port',         'paged' => $paged,         'posts_per_page' => get_theme_option("portfolio_work_count"),                          );                   if (isset($_GET['slug'])) {         $args['tax_query']=array(                 array(                       'taxonomy' => 'portcat',                       'field' => 'slug',                       'terms' => $_GET['slug']                   )              );         }       * * * Ok, I have done exactly as suggested above (except 'category_name' didn't work so am using 'cat_name'). It is still displaying all of the categories...I only want it to display 'Games'. I have included the rest of the code in the hope someone can easily spot what I'm missing?

<?php echo the_title(); ?>

                          <?php echo $firstCat[0]->cat_name; ?>

                          <?php                     $args = array(                     'post_type' => 'port',                     'paged' => $paged,                     'posts_per_page' => get_theme_option("portfolio_work_count"),                     'cat_name' => 'games'                     );                     $wp_query = new WP_Query($args);                          ?>                     <?php while ( $wp_query->have_posts() ) : $wp_query->the_post();                      #We have:                     #get_permalink() - Full url to post;                     #get_the_title() - Post title;                     #get_the_content() - Post text;                     #get_post_time('U', true) - unix timestamp                          $featured_image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail' );                                  echo "

".get_the_title()."
";                             $terms = get_the_terms($post->ID, 'portcat');                             if ( $terms && ! is_wp_error( $terms ) ) {                                  $draught_links = array();                                  foreach ( $terms as $term ) {                                 $draught_links[] = $term->name;                             }                                  $on_draught = join( ", ", $draught_links );                             }                          echo "
".get_the_excerpt()."
                         Read More

                     ";                             endwhile; ?>

             <?php get_pagination() ?>             <?php $wp_query = null; $wp_query = $temp;  ?>


Does wordpress add their own classes into nav menus?

I am building a theme and have noticed that when I create a menu with just html or have it dynamically add menu items based on pages it looks how it was meant to be. Although when I change the code to generate the menu from the menu editor it adds alot of extra padding to the menu. Is this a wordpress issue? Has anyone heard of this before? Here is an example. When I generate a menu using the menu editor it adds padding:

                 <?php wp_nav_menu( array( 'theme_location' => 'primary' ) ); ?>

      When I generate a menu through just hardcoding HTML it looks fine:

Home

About

Portfolio

Support

      Problem has been solved. I removed both the `<ul>` and `<li>` tags and the navigation is in it's proper location.

                     <?php wp_nav_menu( array( 'theme_location' => 'primary' ) ); ?>


how to get the post id in plugin

I have a plugin that I'm working on and I'm having trouble getting the post id so jquery can use it. I'm able to get it using the admin_head hook but I'm not sure how I can return it to jquery. I'm not sure if admin_head is what I need since it does not return anything. Not sure if I can use global? Also this is in the admin screen so not on the front end. Here is what I have so far:               $custom_ID = 0;          function my_custom_admin_head(){         global $post;         $custom_ID = $post->ID;         global $custom_ID;     }     add_action('admin_head', 'my_custom_admin_head');          add_action( 'admin_footer', 'my_action_javascript' );          function my_action_javascript() {?>       <script type="text/javascript" >         jQuery(document).ready(function($) {             $('#get-rates-button').click(function(){               var result = "<?php echo $custom_ID; ?>";               alert(result);             }     }      Is there a function that I could call from jquery that would be able to return the id from a hook or does someone know of a better way? Thanks!


Including javascript for a shortcode

I'm creating a plugin that allows a user to use a shortcode. This shortcode depends on a bunch of javascript that needs to be present once the shortcode loads. I'm having issues trying to decide when and where to load the javascript. Pieces of the code that the shortcode spits out are elements that need to be present, but aren't available for jQuery to utilize. Is there a specific way of loading and attaching scripts that a shortcode relies on?               function build_total_search_method( $atts ) {              $shorcode_php_function = include( dirname(__FILE__) . "/includes/total_search.php" );              return $shorcode_php_function;          }     add_shortcode( 'total_search', 'build_total_search_method' );      This seems to work, but it also prints a `1` to the page. Is this method okay?


wp_paginate not working in combination with WPML plugin?

I have installed the wp_paginate plugin and the WPML plugin. Now I have set 'Dutch' to the basic language and added 'English' as the second language. I set the `Blog posts to display` to: `All posts (display translation if it exists or posts in default language otherwise).` One page shows posts which don't need to be translated. So I left them in 'Dutch'. Only now the wp_paginate doesn't show me the pages in the 'English' version of my site. In the 'Dutch' version they do so up. Here is the code I used:               <?php          $lstrPaged = (get_query_var('paged')) ? get_query_var('paged') : 1;              query_posts('posts_per_page=5&paged=' . $lstrPaged);              if(function_exists('wp_paginate'))          {             if(ICL_LANGUAGE_CODE == 'en')             {                 wp_paginate('title=Page:');             }              else              {                 wp_paginate('title=Pagina:');             }         }      ?>


WP E-Commerce how to report EOY sales to accountant?

Not a development question and I apologize for that, but I couldn't find a good spot to ask it (open to suggestions though). So I need to generate a sales report for the year for my wordpress e-commerce site... and I kinda need California separated. Should I export the SQL table? Since my payments are made via Paypal... should I be looking at PayPal's reporting? Is there a proven plug in to show me sales by state? etc. again... apologies for this question maybe being in the wrong place. Might there be a plug in that does the job or some kind of development hack around e-commerce lacking this feature? Thanks in advance for any help.


How to make in post Parent page children page list nummbered

Parent page veggies Its children pages are carrots peas potato How to put in post numbered list of Parent page? Maybe better how to make same list to be ordered by date posted so some order can be managed by changing dates?


Changed URl in General Settings now Wordpress site doesnt work

My website URL was www.example.com/singer I decided to get rid of "/singer" in the dashboard and ever since i have met with this error.               Fatal error: Call to undefined function wp() in /data/15/3/113/145/3439634/user/3834081/htdocs/singer/wp-blog-header.php on line 14      I've tried multiple methods to fix but all with no luck. Any guidance is appreciated.


Defining the value of a variable before a function?

I'm trying to edit a plugin so that it only shows it's submenu if the user is an administrator but I don't know how to define the value of the variable before the function:               function load_view( $name, $params = array(), $print_submenu_navigation = false ) {      My code so far is:               if (current_user_can('administrator')) {      $print_submenu_navigation = true;       }     else {      $print_submenu_navigation = false;     }      If I put this before the function I get a php error telling me it's expecting a function.


Second select list values are not saved after clicking update

I have a select list in a metabox which value is saved successfully after clicking "Update" when editing post. Of course, the values are custom taxonomies. **But i don't know how to add another select list and make it save its values successfully too...**               add_action( 'add_meta_boxes', 'so_custom_meta_box' );          function so_custom_meta_box($post){     add_meta_box('so_meta_box', 'Reproductor 1', 'custom_element_grid_class_meta_box',     $post->post_type, 'normal'           , 'high');     }          add_action('save_post', 'so_save_metabox');          function so_save_metabox(){      global $post;          if(isset($_POST["custom_element_grid_class"])){          //UPDATE:          $meta_element_class = $_POST['custom_element_grid_class'];         //END OF UPDATE              update_post_meta($post->ID, 'custom_element_grid_class_meta_box',   $meta_element_class);         //print_r($_POST);     }     }          function custom_element_grid_class_meta_box($post){     $meta_element_class = get_post_meta($post->ID, 'custom_element_grid_class_meta_box', true); ?>               <select name="custom_element_grid_class" id="custom_element_grid_class">       <option value="Netu" <?php selected( $meta_element_class, 'Netu' ); ?>>Netu</option>       <option value="Netu-latino" <?php selected( $meta_element_class, 'Netu-latino' ); ? >>Netu Latino</option>       <option value="Netu-castellano" <?php selected( $meta_element_class, 'Netu- castellano' ); ?>>Netu Castellano</option>       <option value="Netu-vose" <?php selected( $meta_element_class, 'Netu-vose' ); ?>>Netu    Vose</option>     </select>            <select name="custom_element_grid_class" id="custom_element_grid_class">       <option value="Vk" <?php selected( $meta_element_class, 'Vk' ); ?>>Vk</option>       <option value="Vk-latino" <?php selected( $meta_element_class, 'Vk-latino' ); ?>>Vk  Latino</option>       <option value="Vk-castellano" <?php selected( $meta_element_class, 'Vk-castellano' );  ?>>Vk Castellano</option>       <option value="Vk-vose" <?php selected( $meta_element_class, 'Vk-vose' ); ?>>Vk    Vose</option>     </select>          <?php     }      Only the first select list values are saved when i click update, but not the second. I already know this has to be with the save code **but i can't figure out how to be able to modify it so i can put a second select list and its value can be saved.**


Displaying Post Title on Post Edit page?

I'm trying to include the post title in a custom post type edit screen. For example if the post is called Biography, I want the edit page title to be 'Edit Biography'. I'm using the below code:               function my_post_register() {      $mypagetitle = $post->post_title;      $labels = array(       'edit_item' => __('Edit '.$mypagetitle),      Why isn't this displaying the post title?


Migrating a page to be an article

I've decided, that some second level pages I have, should really be blog articles. I want to copy and paste the title and body to an article and then delete the page (is there a better way of doing this?). Now I'm worrying about already existing links to the pages. I don't want them to break ... can I somehow enter the old URL as an alias URL for the article? Or maybe forward from http://mypage.com/level-one/level-two-page/ to http://mypage.com/2010/07/30/level-two-page-as-article/ without showing the olt level-two-page in the navigation?