wordpress fancybox responsive mobile or pc version

I just want to have 2 types of fancybox size. for mobiles version width: 95%, height: 85% for pc version - width: 85%, height: 80% How can I set these 2 versions up? should I handle in php with 2 script or is there anyway to modify (handle) in a script?                  jQuery(".openf").fancybox({        'width'   : '95%',        'height' : '85%',        'autoScale' : false,        'transitionIn'    : 'none',        'transitionOut'   : 'none',        'type'    : 'iframe'        });


What's missing in this wp_query and meta_query

There is something missing because this is driving me crazy at the moment. I'm using the wp_query with the following args.               $args = array(         'post_type'     => 'project',         'post_status'   => 'publish',         'meta_query'    => array(             array(                 'key'       => '_sf_project_budget',                 'value'     => '6',                 //'compare'     => '=',                 //'type'        => 'NUMERIC'             )         )            );     $search_query = new WP_Query($args);       When print_r the $search_query I can see the following:               WP_Query Object     (         [query_vars] => Array             (                 [post_type] => project                 [post_status] => publish                 [meta_query] => Array                     (                         [0] => Array                             (                                 [key] => _sf_project_budget                                 [value] => 6                             )                          )       But the "SQL" doesn't seem to change:               [request] =>  SELECT SQL_CALC_FOUND_ROWS  wps_posts.* FROM wps_posts       WHERE 1=1  AND wps_posts.post_type = 'project'      AND (wps_posts.post_status = 'publish')       ORDER BY wps_posts.post_date DESC LIMIT 0, 10      Shouldn't this change to incorporate the meta query vars? Can't see what I'm doing wrong or what's missing, tried different things and it brings all the posts all the time. I checked in postmeta table and I can see that the values are there. Any pointers in the right direction? Thank you.


How to add/assign or change featured image in post programmatically?

I have written a plugin that (besides other functionality) makes posts from existing content. For each post I have one picture - **how to make them featured programmatically**? I do the:               $id =  wp_insert_post( $my_post );     wp_set_object_terms( $id, $cat_ids, 'category' );      and I would like my next step to be inserting $image (file path or URI) as featured image. How? Thanks in advance.


blog change and move to anther hosting for a multisite

I have a multisite and there are 3 blogs. (let's say blog1, blog2, blog3) First question, How can I change the order of blogs? as you may know, blog1 is the main. I want to make blog2 should be the main. I don't feel good to do 301 redirect. I want to change all of them such as files, database. Second question, I need to move blog2 to another hosting and blog2 will be the 1st blog. then all of database name need to change like wp-post2 should be wp- post... etc data files should be also change some part. I think modify files are not a big deal for me. I tested to change database table names manually (wp-post2 to wp-post). it seems to be working fine but I believe this is not good way to do. is there any plugin for both of them? or if I do manually how/what I should do? Thanks, :)


Get media-uploader fields array

I want to modify the fields in the media-uploader.   To do that I need to know what creates the fields. In the Codex, you can see a way to add new fields to the media uploader, using the `attachment_fields_to_edit` filter. You simply add a new field to the array and return it. I thought, that I could modify the function to just print out the array and return it like this:               function my_add_attachment_location_field( $form_fields, $post ) {         print_r($form_fields);         return $form_fields;     }     add_filter( 'attachment_fields_to_edit', 'my_add_attachment_location_field', 10, 2 );      But this does not print out anything. Instead the media-uploader fails to load the images. It loads for ever. Any ideas how to print out the `$form_fields` array?


Custom CSS at Appearance > Edit CSS is missing after update

A WordPress site that I have written a few CSS custom styles for has lost its custom styles. I previously wrote the custom CSS in the Appearance > Edit CSS section of the admin dashboard. But now that menu item is gone from the Appearance menu. And the site no longer has those customizations to its styles. This happened after the site owner “rebooted the site after his hosting provider shut it down for some scripting problem”. I notice that the site has also been updated to the latest version of WordPress, 3.8.1 up from 3.6. The closest option to Appearance > Edit CSS I can find is is Appearance > Editor, which also lets you edit CSS, but only the whole CSS of the theme. I don’t want to put my CSS there, because then it might be overwritten if the theme is ever changed. I also don’t want to use Appearance > Editor because I don’t want to have to rewrite my previous CSS from scratch. – I want the version that I already wrote. I read that my custom CSS might still be available in `wp_options` in the database, but I don’t have access to the site database, as far as I know – I just have an administrator account I can access the dashboard with.


What function actually renders the wp_admin_bar ? How can I call it?

What function actually renders the wp_admin_bar? And how can I call it? I want to print out just the nodes / DOM for the actual menu. It would end up rendering something like this:

                 ....

      I couldn't find it in the documentation anywhere.


Question about proper use of wp_redirect?

I'm attempting to create a Twitter style stream, so basically just index, a tag archive, and maybe a page or two while prohibiting access to everything else. For instance, they try to access a single post page and are tossed back to home. Is this appropriate use of redirects and wp_redirect, and if so, would it be better to create a dummy file (single.php for instance) that only contains wp_redirect or just use conditionals at the top of my header.php? Or am I totally off course?


Simple Amazon Affiliate Plugin

I am looking for a plugin that will embed my amazon affiliate id in outbound amazon links on my blog. I've tried a couple of top plugins (e.g. sorted by popularity) and most are a huge overkill (e.g. providing image popups, search lists, products lists, price integration, etc...) Can someone recommend a plugin that does what I am looking for?


How can I exclude a category from the main loop with the category name & not ID?

I'm having a dozy of a time on this one and have finally had to break down and ask my first question. Usually I can find an answer on here, but this time I need some help. I'm trying to exclude a category from the main loop so that it does not show up twice on my index page. I have searched up and down and came across this code here:                <?php      $category_id = get_cat_ID('featured');      $q = 'cat=' . $category_id;      query_posts($q);      if (have_posts()) : while (have_posts()) : the_post();           the_content();           endwhile; endif;?>      It worked, but then my page navigation didn't work. Even if you clicked on page 2 you still got page one content. Not sure why that happened. I don't want to exclude the category with the ID because the ID will change, but the name will always be the same. Any help on this would be great, Thanks! If you need the demo site then just ask.


wp_query orderby title and meta key value (WP3.1)

I have a taxonomy wp_query and i would like to order the list by **title and** by **meta** value (numeric value)   * Have a meta value Interesting = 1 or 0 in the posts   * Not so interesting posts would be at the bottom of the query **GOAL - OUTPUT LIKE THIS:** (is this possible with WP_QUERY and WP3.1) **A** ( META KEY interesting = **1** ) **B** ( META KEY interesting = **1** ) **C** ( META KEY interesting = **1** ) **A** ( META KEY interesting = **0** ) **B** ( META KEY interesting = **0** )


add_theme_support('custom-header') does not add the option to customize

I am using this to get custom header support to my new theme:               function my_add_header_support() {         $ch_defaults = array(                              'default-text-color'     => '',                              'default-image'          => '',                              );         add_theme_support( 'custom-header', $ch_defaults );     }     add_action( 'after_setup_theme', 'my_add_header_support' );      I expected a headers section to show up under Appearance - Customize in the dashboard, but it does not. There is a previous post about the same problem (theme development - add_theme_support( 'custom-header' ) does not add option menu in dashboard - WordPress Development Stack Exchange). I think it says that support for this should show up in WP 3.4. What am I missing?


Filtering a Database Query

In a WP_List_Table example I'm using, I am seeing how to make a general query to the `wp_options` table in the Wordpress database. For example, `$query = "SELECT * FROM $wpdb->options";` I also see that we typically create a `foreach` loop to display all the records in this table on separate rows. Sounds easy enough. But I would like to filter this query to reference an "options array" instead. This is a single value in my table. For example, I want to query a single option called `testimonial_settings` and then retrieve all the array values from this single field. I can't wrap my head around how I would do this using a `foreach` loop. Maybe a simple example showing the proper syntax would help clear things up....?


Add filter multiple times using only one master function

Is it possible to use add_filter with lets say an array of different values? to achieve something like the following:               foreach($templates as $name) {         add_filter( 'single_template', function ( $template ) {                   global $post;                   if ($post->post_type == $name) {                   $template = dirname( __FILE__ ) . $name . '.php';              }              return $template;         });     }


Logged in only custom page

I have a custom page named **custom.php** then i created a new **page** inside wordpress and selected **custom.php** in the **page attribute template** and **custom.php** page link is accessible in my front page. the custom page shows perfectly, but i plan to make this page a **registered** members only page. i created a custom login page aswell, named **custom_login.php** and i want non members to be redirected here first and upon login, they will access my **custom.php** currently im using a plugin "restrict content" but this plugin displays **404** page and does not meet what i want.. instead i want this to be the **custom_login.php** page


checking the form submit in right order

With help from experts on this site, I have been able to put together a plugin that allows to choose and submit categories from the front-end. Further, in order to make it a bit more secure I have tried to include **nonces and a honey** pot in the form. Although I am pretty sure that my nonce and honeypot are working fine, I am also not sure if I am checking things in the right order. You can see that I have tried to check for the honeypot first and then the main submit and then the nonce. Is it in the right order ? If not, what order should they be in? I believe if I do not check things in right order, I may get unexpected results. Entire plugin code is given below.               add_action('plugins_loaded','wpse_init_crowd_cats_class');     function wpse_init_crowd_cats_class(){         new WPSECrowdCatsClass();     }               class WPSECrowdCatsClass {               function __construct() {                  // APPEND THE FORM AUTOMATICALLY TO EVERY POST             add_filter( 'the_content', array( $this,'append_form' ) );                  // TEMPLATE ACTION TAG TO BE USED IN THEME             // Usage: do_action('wpse_crowd_cats_form');             // Usage: do_action('wpse_crowd_cats_form', $post_id, $taxonomy );             add_action( 'wpse_crowd_cats_form', array( $this,'wpse_crowd_cats_form' ), 10, 2 );                  // FORM PROCESSING             add_action( 'template_redirect', array( $this,'process_request' ) );              }              function process_request(){ // check submission              if(!empty($_POST['pot-net']))         return; //end process if field is not found empty.              if ( ! isset($_POST['crowd-cat-radio']) || ! is_array($_POST['crowd-cat-radio']) )         return;              if (!isset( $_POST['nonce_name'] ) || ! wp_verify_nonce( $_POST['nonce_name'], plugin_basename( __FILE__ ) ) ) {         print 'Sorry, your nonce did not verify.';         exit;        } else {    // continue to process form data                                    // sanitize and check the input             $suggested_terms = array_map( 'absint', $_POST['crowd-cat-radio'] );             $post_id = absint( $_POST['crowd-cats-pid'] );             $tax = $_POST['crowd-cats-tax'];             if ( ! taxonomy_exists($tax) )                 return;                  // Allow only existing terms. Not sure if this is needed.             $args = array( 'hide_empty' => false );             $args = apply_filters( 'mcc_allowed_terms_args', $args, $post_id, $tax );             $args['fields'] = 'ids';             $allowed_terms = get_terms( $tax, $args );             foreach ( $suggested_terms as $key => $term_id )                 if ( ! in_array( $term_id, $allowed_terms ) )                     unset( $suggested_terms[$key] );                  // Add terms to taxonomy             $affected_terms = wp_set_object_terms( $post_id, $suggested_terms, $tax, false );             update_term_cache($affected_terms);             return $affected_terms;              }         }              function get_form( $post_id=null, $tax='category' ) {                  if ( is_null($post_id) || ! taxonomy_exists($tax) )                 return false;                  $args = array( 'hide_empty' => false );             $args = apply_filters( 'mcc_get_terms_args', $args, $post_id, $tax );             $all_terms = get_terms( $tax, $args );                  if ( ! $all_terms )                 return false;                  $post_terms = wp_get_object_terms( $post_id, $tax, array( 'fields' => 'ids' ) );                  $permalink = get_permalink( $post_id );                  $out = "<form id='crowd-cats' action='$permalink' method='POST' >
";                  foreach ( $all_terms as $t ) :                      $checked = in_array( $t->term_id, $post_terms) ? 'checked' : '';                 $out .= "
                             <input type='checkbox' id='crowd-cat-$t->term_id' name='crowd-cat-radio[]' value='$t->term_id' $checked />                              term_id' >".esc_attr($t->name)."
";                  endforeach;                  $out .= "
                        <input type='text' name='pot-net' style='visibility:hidden' value=''/>                        <input type='submit' value='Submit' name='crowd-cats-submit'/>                        <input type='hidden' value='".esc_attr($tax)."' name='crowd-cats-tax'/>                        <input type='hidden' value='$post_id' name='crowd-cats-pid'/>";                                  $out .= wp_nonce_field( plugin_basename( __FILE__ ), 'nonce_name',true,false);             $out .= "</form>";                  return $out;              }                        function append_form($content){                  global $post;                  if ( 'post' != $post->post_type )                 return $content;                  $form = $this->get_form( $post->ID );                  if ( ! $form )                 return $content;                  return "$content \n $form";         }                   function wpse_crowd_cats_form( $post_id=null, $taxonomy='category' ) {                  if ( is_null($post_id) ) {                 global $post;                 $post_id = $post->ID;             }                  echo $this->get_form( $post_id, $taxonomy );         }               } // end of class                    ?>      If you will need me to put this on pastebin and point out the specifically concerned lines of code, please let me know.


I want to use my username to post blog posts, is this advisable?

I only intend to post blog posts with a one word name (the name of the website), and so I am wandering can I just use my username?? Is this common amongst admin-bloggers to post using their username rather than any chosen name they might pick?? The reason I ask is because I do not know what username I would pick other than the one I intend to post with. The only possible reason people might not do this is for the added security of not showing your username.


Include widget within newsletter template?

I'm using the Newsletter plugin (http://wordpress.org/extend/plugins/newsletter/) to compose e-mail newsletters. Using the "auto-compose" feature to pull website data via the theme included with the plugin, which I have begun to customise. It's pulling posts just fine, which is a good start - but I would also like to pull some data that a custom widget on our site is displaying. I'm fairly new to Wordpress and the custom widget in question was not developed by me. Can I include a specific widget via my theme template? Thanks


how to load a file from a plugin when a url is passed

I'm creating a plugin where a file is loaded and if a link is clicked, it passes some variables that are appended to the url. So if a link is clicked it will change the url by appending `filter/?term=il_Massac,st_locked` which should load the `filter.php` file. My issue is how do I get it to use the `filter.php` which is included in the plugin? The main plugin file is called `meta-box.php`. If I added it the the theme as a page, it works but I want the plugin to do the work instead of adding a page. Right now, if I don't use it as a page-template in the theme folder and just have it in the plugin folder, it gives a 404. Here is the code to the link that is in my meta-box.php file: ` <a href="<?php echo home_url()?>/filter/?term=<?php echo $term ?>">search link</a>` $term is a variable that has some search parameters in it. So if I click that link, it gives me the 404 page rather than loading the filter.php file to execute some code. Again, I can add it the the theme as a page template but I would like it to be contained within the plugin so it does not need to be added to the theme as a page template. Does that help? Any suggestions on how I might do this?


custom query to get posts

I want to create custom links like `mydomain.com/custom_page/cat=ABC&tag=XYZ` So that when a user clicks on the link s/he can see all posts in the category 'ABC' having tag 'XYZ' For this I've created a custom template with the following code               <?php     /*     Template Name: MyCustomTemplate     */     ?>          <?php get_header(); ?>     global $wp_query;     get_query_var( 'cat' );     get_query_var( 'tag' );     <?php get_footer(); ?>      I don't know how to query for the posts in the category 'ABC' with the tag 'XYZ' I checked http://codex.wordpress.org/Function_Reference/query_posts#Passing_variables_to_query_posts but the examples shown there use 'static' values. I need to query using dynamic values: which are passed via the URL. Also, I'm using a plugin 'Advanced Custom Fields' and have added a field 'priority' with the defult value 'Z'. I intend to assign one alphabet to each post in the priority field, so that results on the page are served sorted according to "priority" : Posts with the priority 'A' on the top, followed by posts with priority 'B' and so on.. **In Short** : I want to get category and tag parameters from links like: `mydomain.com/custom_page/cat=some_category&tag=some_tag` Then Fetch posts in the category 'some_category' AND having tag 'some_tag' AND sorted according to custom field : 'priority'


Function to retrieve a picture if there is no picture is attached

How can i retrieve a picture, let say ( No picture ) when i don't add a picture in my custom field I use this code to retrive the field...               <img class="film"           src="/scripts/timthumb.php?src=<?php the_field('img_actor'); ?>&h=251&w=175&zc=1"          alt="<?php the_title(); ?>"            title="<?php the_title(); ?>"/>      How to retrive no-picture from this code               <?php      if(get_field('distributie') != ""){$counter=0;foreach(get_field('distributie') as $post_object): ?>
     <a href="<?php echo get_permalink($post_object->ID); ?>" title="Actor <?php echo get_the_title($post_object->ID) ?>">     <img class="actor_img" src="/scripts/timthumb.php?src=<?php echo get_field( 'img_actor', $post_object->ID ); ?>&h=70&w=50&zc=1" alt="<?php echo get_the_title($post_object->ID) ?>" title="<?php echo get_the_title($post_object->ID) ?>" />                  <a href="<?php echo get_permalink($post_object->ID); ?>" title="Actor <?php echo get_the_title($post_object->ID) ?>"><?php echo get_the_title($post_object->ID) ?>
     <?php $counter++;if($counter>=8) break; endforeach;}?>      If i change               <?php echo get_field( 'img_actor', $post_object->ID ); ?>      with               <?php echo urlencode($img); ?>      I get an error ($post_object->ID) where do i put it?


PHP echo text being output in incorrect order

In footer.php, I have the following code:               <?php         $copyYear = 2011;          $curYear = date('Y');          echo "© " . $copyYear . (($copyYear != $curYear) ? '-' . $curYear : '') . " " . bloginfo('name');     ?>      On the front page of the website, the following is output: > Sugar Gum Cakes© 2011-2014 Note the Blog name is at the start, while in the PHP code it is at the end. Why is this happening? I can't see how it would be CSS. Thanks.


htaccess – Server Subdirectory With Different Name Than URL Subdirectory

I have a client with an odd setup that I can’t quite figure out and I thought someone here might know the answer. I’m not sure they want the site shared, so I’ll use `example.com` for the sake of explanation. Their wordpress URL is setup like `http://example.com/blog`. However, on the server (Apache), the actual folder is called “wordpress” NOT ”blog”. The `.htaccess` is located in the “wordpress” folder (full server path is `/var/www/wordpress/`) and looks like this:               # BEGIN WordPress     <IfModule mod_rewrite.c>       RewriteEngine On       RewriteBase /blog/       RewriteRule ^index\.php$ – [L]       RewriteCond %{REQUEST_FILENAME} !-f       RewriteCond %{REQUEST_FILENAME} !-d       RewriteRule . /index.php [L]     </IfModule>          # END WordPress      There is no .htaccess in `/var/www/` In General Settings they have this:   * WordPress Address: `http://example.com/blog`   * Site Address: `http://example.com/blog` This works fine on WordPress pages, posts and categories. But some plugins (gravity forms, nextgen) will strip out the “blog” portion of the URL when using them. So for example a Gravity Form will try to submit to `http://example.com` instead of `http://example.com/blog` which will cause an error. My guess is that `.htaccess` is configured wrong but `.htaccess` and regular expressions are my weak point.


Plugin development without Theme adjustments?

_I'm an ambitious wordpress beginner and learner - this is my first question at Stackexchange - in case I'm wrong here, I'm grateful for anyone pointing in a better direction._ On my page http://www.project22.org   * I started off with a childtheme of Twenty Twelve, because I thought this theme is particularly well prepared for anything that might come.   * Next I created my own 'base-functionality-plugin', to do the programming that I (didn't find in other plugins) and that I wanted to do myself. Now, I have basically created the functionalities I wanted in my plugin, but to display my results I needed to some adjustments in the (child) theme files, e.g. the content.php to change the display of the "entry_meta" of posts. This doesn't feel right, wouldn't it be best if my plugin remains independent of the theme itself? So my beginner questions are these:   * How to avoid this?   * What is the best practice regarding this?   * What to do if your starting theme has no hooks or filters in the places you need? Edit: My use case - in the entry_meta of each post I want to display some data from custom fields. The only solution I found was to make adjustments to the theme function `twentytwelve_entry_meta();` \- but this won't work on a different theme, right?


dates under post titles -- also showing up under Nav

I added a filter in `functions.php` in order to have the dates show up under my titles on each Post on my homepage. Random dates are now also showing up in the Nav. Can someone help me make those go away? I'm happy they show on the posts now, so I did something right! But the dates in the Nav have got to go! I'm developing the site here: internalcompass.us/castle and I used this code in the child theme twentytwelve in the functions.php to add the dates:               <?php     function add_dates_to_title_wpse106605($title, $id) {     if (is_home()){         $time = get_the_time( $d = 'l, F j, Y', $post = $id );         return $title . '
' . $time . '';     } else {         return $title;     }     }          add_filter('the_title', 'add_dates_to_title_wpse106605', 10, 2);     ?>


how to show category post and title separate with auto number

i am making one slider tab, i know have tons of plugins for that but i don't want to use plugins. so i want to show my category post title and post like bellow html formate but i can't. i tried my but my way only content loop not title. if can able to make html like bellow then tabs will work. guys how can i do that.

Tabs 1

Tabs 2

Tabs 3

Tabs 4

Tabs 5

Horizontal Tab #1

Lorem ipsum dolor sit amet, duis netus ut posuere feugiat arcu, purus wisi quis fringilla at, nunc ut eget elit duis erat praesent, ut fermentum lacus turpis cras. Justo gravida erat quam mauris purus, aliquam quisque, eget nisl. Pellentesque nibh duis odio morbi quam, scelerisque convallis aenean quam tincidunt ornare nam nec feugiat sodales tristique.

Horizontal Tab #1

Lorem ipsum dolor sit amet, duis netus ut posuere feugiat arcu, purus wisi quis fringilla at, nunc ut eget elit duis erat praesent, ut fermentum lacus turpis cras. Justo gravida erat quam mauris purus, aliquam quisque, eget nisl. Pellentesque nibh duis odio morbi quam, scelerisque convallis aenean quam tincidunt ornare nam nec feugiat sodales tristique.

Horizontal Tab #1

Lorem ipsum dolor sit amet, duis netus ut posuere feugiat arcu, purus wisi quis fringilla at, nunc ut eget elit duis erat praesent, ut fermentum lacus turpis cras. Justo gravida erat quam mauris purus, aliquam quisque, eget nisl. Pellentesque nibh duis odio morbi quam, scelerisque convallis aenean quam tincidunt ornare nam nec feugiat sodales tristique.

Horizontal Tab #1

Lorem ipsum dolor sit amet, duis netus ut posuere feugiat arcu, purus wisi quis fringilla at, nunc ut eget elit duis erat praesent, ut fermentum lacus turpis cras. Justo gravida erat quam mauris purus, aliquam quisque, eget nisl. Pellentesque nibh duis odio morbi quam, scelerisque convallis aenean quam tincidunt ornare nam nec feugiat sodales tristique.

Horizontal Tab #1

Lorem ipsum dolor sit amet, duis netus ut posuere feugiat arcu, purus wisi quis fringilla at, nunc ut eget elit duis erat praesent, ut fermentum lacus turpis cras. Justo gravida erat quam mauris purus, aliquam quisque, eget nisl. Pellentesque nibh duis odio morbi quam, scelerisque convallis aenean quam tincidunt ornare nam nec feugiat sodales tristique.

      see closely `href="#content_1" rel="tab_1"` this #content_ (1,2,3,4,5)should auto. similar `<div id="content_1"` this content_ also number will auto i mean post number


Resize header image

How can I access to the css file where is the header's background image?               background: url("http://xxx.es") no-repeat scroll center top / 1600px auto transparent;      It's not in the style.css


How to add a class to meta boxes (to customize them in CSS)?

I have an situation: I just can't figure out how to add classes to some meta boxes.   I read these post from here, I tried this solution, but it did not work as I wanted. Is there a way to add classes (to customize them in CSS) to meta boxes?   For example in this case:                 array(         'label' => 'a name',         'desc'  => 'description',         'id' => 'id_x',         'type' => 'select',         'options' => array('Bad', 'Good', 'Excellent'), /* HERE I WANT A CLASS FOR EACH THIS GUYS (to customize them in CSS) */         'std' => "         ),      I want that the HTML to look like this:               Bad     Good     Excellent


Blog posts on one subdomain, pages on another

I'd like to use blog.example.com as the base for my blog posts, e.g. http://blog.example.com/2013/08/29/sample-post/ and www.example.com for my pages, e.g. www.example.com/about-me/ Is there an easy way to do this? I tried with creating a network but that gives me two WordPress installations, both with posts and pages and their own admin dashboards. I just want to go posts to one subdomain, pages to the other.


Theme Options Menu Item - Permission Issue

I am trying to create a theme options menu item for my custom theme. However, when I add the following piece of code in the functions.php file...               add_menu_page('Page title', 'Asteria', 'manage_options', 'ThemeOptions', 'my_magic_function');      It gives me the following error when clicking on the menu item... > You do not have sufficient permissions to access this page. The entire folder, and all contents are 777'd. I am logged in as an administrator. I have tried this on 2 different servers. One of the servers is running a network of blogs (the preferred server), the other is just a single blog setup. Any ideas on where I went wrong?


custom Background not showing after upgrade?

I've been using wp3 custom background feature. Today I updated to the latest version and now my custom background isn't showing. Strange thing is Appearance > Background still shows the custom background I'm using. Has anyone seen this problem? Thanks in advance.


Modify "Recent Comments" List in WP-Admin

This one might be a little tricky, but I'm looking for a way to make the Recent Comments widget on the wp-admin a bit more useful/action-driven. I'd like to be able to filter to only show the Pending comments (as those would require an action to them). I saw on line 45 of `wp- admin/includes/dashboard.php` there is:               // Recent Comments Widget         if ( is_blog_admin() && current_user_can('moderate_comments') ) {             if ( !isset( $widget_options['dashboard_recent_comments'] ) || !isset( $widget_options['dashboard_recent_comments']['items'] ) ) {                 $update = true;                 $widget_options['dashboard_recent_comments'] = array(                     'items' => 5,                 );             }             $recent_comments_title = __( 'Recent Comments' );             wp_add_dashboard_widget( 'dashboard_recent_comments', $recent_comments_title, 'wp_dashboard_recent_comments', 'wp_dashboard_recent_comments_control' );         }      but I'm a little fuzzy on the correct way (or if there is a way) to hook into this to modify the "types" of comments shown. Any help would be greatly appreciated. Thanks!


melville and its child theme

hello guys im making child theme of melville and i wanna make a custom page with a static menu (as in not made with wp ) of my own and under it i wanna display the content and i use this `get_template_part('loop' ,'home- page')`where the home-page its name of my custom page and i do have the loop file in my child theme please if anyone knows whats my msitake i would be thankfull my issue is the content doesnt show up Edit : here's my code im using nothing fancy `                get_header(); ?>             some xhtml here               <?php get_template_part('loop' ,'home-page') ?>         <?php //comments_template( '', true ); ?>           <?php get_footer(); ?>      `


Wrap meta boxes & data handling for specific post types in classes?

I have a site with a few custom post types, each with their own custom data, meta boxes & assets (stylesheets, images, JavaScript). Typically I'd hook onto `add_meta_boxes` to register all my meta boxes and `save_post` to handle the data, but in this case I'd like to wrap all the functionality for each post type in a class & abstract out the process of instantiation. My proposal is as follows;               function my_prefix_admin_load_post()     {         /* Grab current post type - can't use global $post_type since it isn't set yet! */         if ( isset( $_GET['post'] ) )             $post_type = get_post_type( $_GET['post'] );         elseif ( isset( $_REQUEST['post_type'] ) )             $post_type = basename( $_REQUEST['post_type'] );         else             $post_type = 'post';              /* Construct classname & filename from post type. */         $post_type_file = dirname( __FILE__ ) . "/inc/class-post-$post_type.php";         $post_type_class = 'Class_Prefix_' . ucfirst( $post_type );              if ( is_file( $post_type_file ) )             require $post_type_file;              if ( class_exists( $post_type_class ) )             new $post_type_class;     }     add_action( 'load-post.php', 'my_prefix_admin_load_post' );     add_action( 'lost-post-new.php', 'my_prefix_admin_load_post' );      This way, I can drop in enhancements for a new or existing post type at anytime (without tinkering with my base functions), and without code for different post types intermingling with another. **However** , I can't help but feel the loading process is just a little... icky. **I'd really love to hear of suggestions, whether improvements or alternate approaches!**


Admin Theme customization

I followed instruction on the wordpress codex site on creating an admin theme via a plugin. I activated the plugin, but my stylesheet isn't being included in the `<head>`.. Here's my code:               add_action( 'admin_init', 'kd_plugin_admin_init' );     add_action( 'admin_menu', 'kd_plugin_admin_menu' );          function kd_plugin_admin_init() {        /* Register our stylesheet. */        wp_register_style( 'kdPluginStylesheet', WP_PLUGIN_URL . '/admin-theme.css' );     }          function kd_plugin_admin_menu() {        /* Register our plugin page */        $page = add_submenu_page( 'edit.php',                                   __( 'KD Plugin', 'kdPlugin' ),                                   __( 'KD Plugin', 'kdPlugin' ),                                  'administrator',                                  __FILE__,                                   'kd_plugin_manage_menu' );             /* Using registered $page handle to hook stylesheet loading */        add_action( 'admin_print_styles' . $page, 'kd_plugin_admin_styles' );     }          function kd_plugin_admin_styles() {        /*         * It will be called only on your plugin admin page, enqueue our stylesheet here         */        wp_enqueue_style( 'kdPluginStylesheet' );     }          function kd_plugin_manage_menu() {        /* Output our admin page */     }


Build Categories List for Posts with specific meta_value

I've a set of Posts under custom post type that has a specific custom field (meta_value). This posts are categorized with a simple Common Parent->Child#N relationship. The question is how to list all categories (similar to `wp_list_categories(): "%Category_Page_URL% (%post_count%)"`), considering the fact that I need to get categories that have posts with specific meta_value. Question can be read as: "Build category list for posts where meta_value = `$foo`"


How can I make new .css file in child theme override styles in child theme's style.css

I want to make a separate responsive.css file in my child theme but having trouble making the media queries override the styles in the child theme's default style.css. I've tried putting `<link rel="stylesheet" href="<?php echo get_stylesheet_directory_uri(); ?>/responsive.css" type="text/css" media="screen"/>` after the `<?php wp_head(); ?>` code, which works, but I've read that this is not good practice. I do not really want to add the media queries to the end of style.css as it's already large and getting quite confusing!


find pods item where relationship to other pod is not set

I need to fix the effect of an error that left empty a relationship field that should have been autofilled. To fix this I need to find all pods item that has the relationship not set, but I don't know how to do it. I tried with `'where' => 'source.id = ""'` in a `find()` but with no luck. Any idea?


All "Featured Images" not displaying after Wordpress update

After updating to the latest version of WordPress today, I noticed that all "Featured Images" on my website are no longer displaying. After trying to figure the problem out for hours, I added the below to my `functions.php`:               if ( function_exists( 'add_theme_support' ) ) {         add_theme_support( 'post-thumbnails' );     }      This fixed the problem in Firefox and all images are showing again. But unfortunately, the images are still missing when viewing the website in Internet Explorer and Chrome. Is there another code I need to add in `functions.php` or perhaps in the CSS file?


need a wordpress loop to put in the sidebar

I need WordPress loop to do the following : check if there is no sidebar widgets active then get 5 recent posts with only titles and thumbnails But here is the thing : I don't want the loop to get the featured post thumbnails but a unique thumbnail based on post category and get them form a folder in the theme directory named:" images" where I will put image for each category in this folder so that the loop get them by category ID or slug maybe. I hope I made it clear to you cause I'm stuck with a project and I need help from php expert. I have a code It may be useful if tweaked :
     <?php     $pc = new WP_Query('orderby=comment_count&posts_per_page=5'); ?>              <?php while ($pc->have_posts()) : $pc->the_post(); ?>
              <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_post_thumbnail(array(75,75)); ?>         <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?>
              <?php endwhile; ?>
      Note ( I am using child theme for twenty twelve theme )


How properly write function to filter content in a template for plugin "multiple content blocks"

In a website I'm building (using my own designed theme, for a business site that doesn't have a blog, IOW, using WP for it's CMS), I have 5 templates: the homepage, the 404 page, the default (page.php), a small one-column and a large one-column. I use the default template for 6 pages in the site. That template is 2-column with a wide main column and narrower right column. But each page will have different content in the right column - mostly text - so it's really not a "sidebar" situation. I want to use the plugin "Multiple Content Blocks". I used it in the homepage template and it's easy and works beautifully, but all I had to do was place this code:               <?php the_block('blockname'); ?>      in the template in my "colR" div. In actual fact the code is:               <?php the_block('News'); ?>       as I named the block "News". So far so good. In the readme.txt it has the following FAQ: How do I filter the content?, and it says: "Use the function get_the_block instead of the_block, like this: `<?php $content_to_edit = get_the_block('blockname'); ?>` and you can now edit this variable with PHP." I'm ASSUMING (perhaps incorrectly) that this means I can write a function or filter for the plugin -- what I want to be able to do is name a block for each of the six pages, and then in the page.php template, be able to specify "if this page, use this block" but I don't know how to write it. So, for example, if one of the pages is called "customer", or ID 21, and I want to name the content block "contact", what exactly goes in the `$content_to_edit` part? I've tried a couple things but they haven't worked. Also, would it need to go inside the loop? In my page.php I have the loop above the colR (for column right) div. Help greatly appreciated!


Trouble inserting string containing quotations marks with wpdb in save_post hook

I'm having trouble with inserting a string which is containing quotation marks in wordpress via wpdb. I've written a hook for save_post and trying to write the post_title in a table via wpdp->update. String is taken straight from the $_POST array. Unfortunatly, in the db the string is saved with escaped quotation marks. this is "the" example will become -> this is \"the\" example printed out in html. How can I prevent this? Code looks like this:               $data = array(  'post_content' => $new_content,                                 'post_title' => $new_title);                      $wpdb->update('wp_'.$blog_id.'_posts', $data, array('ID' => $post_id));


Making a Killer wp_link_pages

I am trying to achieve a similar look to the image below, a working example can be found here: http://www.menshealth.com/celebrity-fitness/mark-wahlberg- fighter-workout ![example](http://i.stack.imgur.com/9l9cv.jpg) **The needed code must do the following (some of my questions have been answered, but these remain):** > Turn the non-linked active/current page number into a link to the top of the > page. > > Assign a unique style class to the previous and next links My current code is in use on this site. The code below is what I have so far. Calling it               <?php     wp_link_pages(array(         'before' => '
' . __(''),         'after' => '
',         'next_or_number' => 'next_and_number', # activate parameter overloading         'nextpagelink' => __('Next'),         'previouspagelink' => __('Previous'),         'pagelink' => '%',         'echo' => 1 )     );     ?>      Custom function               // Custom Next/Previous Page     add_filter('wp_link_pages_args', 'wp_link_pages_args_prevnext_add');     /**      * Add prev and next links to a numbered link list      */     function wp_link_pages_args_prevnext_add($args)     {         global $page, $numpages, $more, $pagenow;              if (!$args['next_or_number'] == 'next_and_number')              return $args; # exit early              $args['next_or_number'] = 'number'; # keep numbering for the main part         if (!$more)             return $args; # exit early              if($page-1) # there is a previous page             $args['before'] .= _wp_link_page($page-1)                 . $args['link_before']. $args['previouspagelink'] . $args['link_after'] . ''             ;              if ($page<$numpages) # there is a next page             $args['after'] = _wp_link_page($page+1)                 . $args['link_before'] . $args['nextpagelink'] . $args['link_after'] . ''                 . $args['after']             ;              return $args;     }


Custom filter for the_content doesn't work correctly

=====THIS POST HAS BEEN UPDATED===== SCROLL TO THE BOTTOM TO READ THE UPDATE! I asked a question yesterday that a gentleman named Tim was nice enough to take a stab at. He helped me through writing a filter that will enable me to append the_content with a custom meta box I created using Advanced Custom Fields. Tom got me through almost the entire process, but unfortunately wasn't able to help me complete it. I am no pro programmer by any stretch, but I have (for the last few hours) tried to decipher what his code means and why it might be failing to pull in the text from the back end... And I keep coming up short. Here is the link to my previous post : It takes you from start 'till now and here is the code I have right now:               function weedub_affiliate_filter($content) {     $string_to_add = '';     // only add on single posts with aff checkbox and label     if (is_single() && get_field('affiliate_checkbox') && get_field('affiliate_label')) {         $string_to_add = $string_to_add . '

             Weedub Product Recommendations
';         while (the_repeater_field('affiliate_label')) {             // list affiliates             $string_to_add = $string_to_add . '

                     ' . get_sub_field('label_affiliate') . '

                                                              ' . get_sub_field('text_for_link_affiliate') . '

';         }         $string_to_add = $string_to_add . '
';     }     $content = $content . $string_to_add;     return $content;      `}` `add_filter('the_content', 'weedub_affiliate_filter', 9);` This snippet is ALMOST there, it is displaying in the right place, and it is recognizing that I have entered 3 rows of fields on the backend, but it is not printing the text from the fields. example (scroll down the page till you see where I have written END OF THE_CONTENT in heading case) : Look for the "Weedub Product Recommendations" box Any and all help is soooooo appreciated! THANKS -Aaron =====UPDATE==== So, I found out that the code DOES actually print the values, but it prints them BEFORE the_content, and the markup AFTER the_content!! look just before the content actually starts (after the featured image) and you will see the string of values... then scroll down to the end of the_content and you will see the markup for the meta box, (titled "weedub product recommendations") here is the link again: link to single post I can't figure out where I am going wrong here!!


wp_nav_menu transferred to other domain using JSONP - menu not echoed in correct place

I have a WP website, and a related shop that's on a different domain / site. I want to have one navbar that I can update in wordpress that will also update the shop without me having to do it twice. Aiming to do this using some JS like this:               $.getJSON("http://some-wordpress-site/menu-only/?jsonCallback=?", function(json) {                 $('#navWrapper').append();      });      In the **menu-only** template, I'm trying to create application/json feed for the shop to read and spit out the menu. I.e.:               <?php     /*       Template Name: Menu Only      */     header('Content-type: application/json');     ?>     <?php echo htmlentities($_GET['jsonCallback']) ?>     (     <?php     echo json_encode(array(         'content' => wp_nav_menu(array('echo' => false, 'menu' => 'Navigation', 'container_class' => 'menu-header', 'walker' => new mainnav_menu_walker())))     )     ?>     );      What ends up happening when I visit my JSON menu link on the WP site is the wp_nav_menu has spat itself out in the wrong location. The result (without copy/pasting a huge chunk of code in here) looks a bit like this:               (     ... massive menu html code block ...     {"content":false});     );      Whereas the menu should be echoing where false is. Has anyone had experience with wp_nav_menu acting oddly like this? I have a fairly complicated walker operating behind it, which works fine on the wordpress site.


IE 9 Clears Form Fields

This is a really strange issue that I cannot seem to solve. I have several forms (login, registration, and other) outputted on a site via short codes. When the forms are submitted, their data is processed via an "init" hook that listens for the $_POST data. When the forms are submitted in IE 9, all fields are cleared of the values when clicking submit. For example, let's say there is an input field with a name of "username", and the field's value is set to "johndoe"; when submitting the form through any browser besides IE 9 (include 7 and 8), the data comes in like this: `$_POST['username'] = 'johndoe'` Exactly as expected. However, when the form is submitted with IE9, it comes out like this: `$_POST['username'] = ''` As far as I can tell, it happens with every form on the site. The custom login form I've built, for example, looks like this:               <form id="re_login_form" class="re_login_form" action="" method="post">         <fieldset>                 <?php _e('Username', 're'); ?>                 <input name="re_user_login" id="re_user_login" class="required" type="text" title="<?php _e('Username', 're'); ?>"/>         </fieldset>          <fieldset>                 <?php _e('Password', 're'); ?>                 <input name="re_user_pass" id="re_user_pass" class="password required" type="password"/>         </fieldset>         <fieldset class="form-action">                 <input type="hidden" name="refalf_redirect" value="<?php echo $redirect; ?>"/>                 <input type="hidden" name="re_login_nonce" value="<?php echo wp_create_nonce('re-login-nonce'); ?>"/>                 <input id="re_login_submit" type="submit" class="button re_submit" value="<?php _e('Log In', 're'); ?>"/>
<a href="<?php echo wp_lostpassword_url( get_permalink() ); ?>" title="<?php _e('Lost Password', 're'); ?>"><?php _e('Lost Password?', 're'); ?>
         </fieldset>      </form>      One of the things that is extra interesting is that the fields are visibly cleared of their values when clicking submit in IE9. It's also as though the submit button is triggering something in IE9 that clears the fields. Anyone have any ideas?


How do I secure a subdomain using UCC SSL?

I have a UCC SSL Certificate installed on my primary domain (example.com). I have 3 subdomains listed as Subject Alternative Names (SANs) (shop.example.com, distributors.example.com and careers.example.com). Currently, I'm working on the shop subdomain. I installed the Wordpress HTTPS (SSL) plugin, but when I try to go to say, (link 1) https://shop.example.com, it redirects to (link 2) https://example.com. I cannot for the life of me figure it out. I tried changing the WordPress Address (URL) and Site Address (URL) in General Settings to https instead of http and at least it didn't redirect me to login to the example.com, but directly typing in (link 1) still directed me to (link 2). Also, that created another problem.....none of my media would show. I have "Googled" for days and cannot find a solution.


Looking for a PayPal donation plugin similar to JoomDonation

http://joomdonation.com/index.php?option=com_content&view=article&id=23&Itemid=12 I'm creating a non-profit website for a very big charity, and I'm ~~looking~~ NEEDING a plugin to handle donations via PayPal. I've been searching for over 2 days, nearly 8 hours straight for a donation plugin that connects to Paypal to get a balance toward a goal, and has a customizable "Goal" image so they can use their own images. I'd like it to also be able to show the latest donators (Possibly all of them if needed) so they can give credit where it is due. (They sometimes run contests involving the donators, so it would need to keep track of all the donators) I've tried nearly everything, but the only thing that even comes remotely close is a Joomla extension. I don't care if I have to have 2-3 different plugins to get it working, but it needs to be automated, so no manual updating of the goals to make it work. I'm really out of ideas to find anything.... I'm open to Commercial plugins, as long as it has my needs.


wp_editor in thickbox

I am updating a shortcode generator that I made before and I want to add in addition to text areas inputs etc.. a tinymce editor, so I call wp_editor in the ajax content of the thickbox, the editor appears but without any buttons and when switching to visual tab I get this error               Uncaught TypeError: Cannot read property 'canvas' of undefined load-scripts.php?c=1&load%5B%5D=hoverIntent,common,admin-bar,schedule,wp-ajax-response,autosave,jqu…:46      any ideas?


how to show perticular category posts in custome page

i know how to define custom post template vai plugins very easily but i want without plugins how can i define custom post template for particular category post. say like i have one category "members" under this category have ten post. so i want when show those member post that time show custom template. see bellow code from twentytwelve theme category.php file               <?php                 /* Start the Loop */                 while ( have_posts() ) : the_post();                          /* Include the post format-specific template for the content. If you want to                      * this in a child theme then include a file called called content-___.php                      * (where ___ is the post format) and that will be used instead.                      */                     get_template_part( 'content', get_post_format() );                      endwhile;                      twentytwelve_content_nav( 'nav-below' );                 ?>                  <?php else : ?>                 <?php get_template_part( 'content', 'none' ); ?>             <?php endif; ?>       see in above code say `get_template_part( 'content', get_post_format() );` and see `get_template_part( 'content', 'none' )` now i want when "members" category post will open it will one custom page.. like `content-members.php` file, so i think code will be like that `get_template_part( 'content', 'members' )` so how can define in category page members category post will open content- members.php file


local WAMP admin user has lost privileges

I have a Wordpress 3.4.1 installed on a local WAMP server. I am in the process of upgrading it to a network, but I now realise my admin account has no admin privileges:   1. No access to the Updates page (update-core.php) - I receive "You do not have sufficient permissions to access this page."   2. No ability to install plugins.   3. No ability to edit users.   4. No ability to go to Tools > Network Setup - same error as above.     * The **wp_capabilities** of my user account is **a:1:{s:13:"administrator";b:1;}**     * The **wp_user_level** is **10** What is wrong here? **Update** \- I added another admin account using PHPMyAdmin following this tutorial, but I receive the same symptoms for this 2nd admin account.


limit posts per page

I am working with category.php. I have my posts returning how I want them, I am getting the child categories how I want them but now I am trying to add pagination and limit the amount of posts to 3. When I ran my test, the 4th post showed up on the page. I was expecting only 3 and the pagination at the bottom. I am not sure what is wrong. According to the codex, this should be working.                $allcats = get_categories('child_of='.get_query_var('cat'));      foreach ($allcats as $cat) :     $args = array(      'category__in' => array($cat->term_id)     );          $customInCatQuery = new WP_Query($args);           if ($customInCatQuery->have_posts()) :      echo '
';                  $terms = apply_filters( 'taxonomy-images-get-terms', '' );             if ( ! empty( $terms ) ) {             foreach( (array) $terms as $term ) {                     if($term->term_id == $cat->term_id) {                       echo wp_get_attachment_image( $term->image_id, 'menu' );                     }             }             }          echo '
'.$cat->name.'
';     echo '
';         while ($customInCatQuery->have_posts()) : $customInCatQuery->the_post(); ?>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?>
           <?php      endwhile;       echo '

';            ?>           <?php else :       echo 'No post published in:'.$cat->name;                      endif;       wp_reset_query();      endforeach;            ?>       <?php if ( $wp_query->max_num_pages > 1 ) : ?>
<?php next_posts_link( __( '← Older posts', 'paradiso' ) ); ?>

<?php previous_posts_link( __( 'Newer posts →', 'paradiso' ) ); ?>
         <?php endif; ?>


Missing thumbnails

For all the pics I upload to Wordpress I get such a link to the pic:               src='http://myblog.com/wp-content/themes/mytheme/thumb.php?src=wp-content/uploads/2012/06/mypic.jpg&w=100&h=100&zc=1&q=90'      Anf ofcourse Wordpress does not find it. But if I change to with the firebug:               src='http://myblog.com/wp-content/uploads/2012/06/mypic.jpg'      Wordpress displays the picture. Where I should look for the problem? Thanks.


wp.media upload PDF Thumbnails

I am using PDF Thumbnails to create jpgs from uploaded pdf. The newly created jpg is not showing in the media library until the media manager is closed and reopened. How can I get the new jpg to show as a selectable object in the media library after it is uploaded? This is how I call the wp.media.frame:               $('body').on('click', '.manage-media', function() {//Manage Media button                 if ( $(this).attr('data-gp-multiple') == 'false' ){             field.multiple = false;          } else {             field.multiple = true;         }         field.mediatype = $(this).attr('data-gp-mediatype');         field.name = $(this).attr('data-gp-name');         field.id = $(this).attr('data-gp-id');         input = $(this).parents(".gallery_meta_box_parent");         var media_id = $(input).val();         var frame = wp.media({                     title : "Pick your "+field.name+" for this Gallery",                     multiple : field.multiple,                     library : { type : field.mediatype},                     button : { text : "Insert" },                     stack: false             });                  frame.on("close",function() {                 console.log('close');             }                  frame.on("open",function() {                 selection = frame.state().get("selection");                  ids = $(input).val().split(",");                 ids.forEach(function(id) {                     attachment = wp.media.attachment(id);                     attachment.fetch();                     selection.add( attachment ? [ attachment ] : [] );                 });             });             frame.open();     });


Output yearly archive within a page

I've almost got what I want working from cobbling bits but I need a bit of help finishing it up. What I'm trying to do is output the following (for a custom post type) within a page template (not a separate archive page):

2014

12 September 2014
             "Post title 1

11 August 2014
             "Post title 2

10 May 2014
             "Post title 3

2013

20 June 2013
             "Post title 4

19 April 2013
             "Post title 5

18 January 2013
             "Post title 6

      The code I've got so far looks like this:               <?php     $years = $wpdb->get_results( "SELECT YEAR(post_date) AS year FROM wp_posts WHERE post_type = 'press-releases' AND post_status = 'publish' GROUP BY year DESC" );          foreach ( $years as $year ) {         $posts_this_year = $wpdb->get_results( "SELECT post_title FROM wp_posts WHERE post_type = 'press-releases' AND post_status = 'publish' AND YEAR(post_date) = '" . $year->year . "'" );              echo '
';         echo '

' . $year->year . '
';         foreach ( $posts_this_year as $post ) {             echo '
' . $post->post_title . '
';         }         echo '
';         echo '
';     }     ?>      Which is the basics of what I want. However, I also need to wrap the post title in the permalink and output the the date the post was published. I'm sure it's a simple fix but I don't know how to do it. Any ideas or is there a better way to do what I'm trying to achieve? Any input appreciated, thanks!


Changing a link to be translatable in WPML String translation (example included)

I have an specific example. This Title "Filme" / $title in the Sidebar Widget should link to another site - yet be translatable. "Filme" shows up in the String Translation but does not translate. Therefore I want to make it translatable, changing the code. (see widget in right side bar: http://www.rasmus-sievers.de/WordPress_02/film/alles-was-wir-wollen/) ORIGINAL code:                   if ( !empty( $title ) )      {echo $before_title . $title . $after_title;};      MY CODE (entered the link, works but not translatable)               if ( !empty( $title ) )      {     echo $before_title;      echo 'Filme ';      echo $after_title;     };      MY TRIAL (which had the php file crash):               if ( !empty( $title ) ) {      echo $before_title;     echo '< ?php _e( 'Filme', 'mthemelocal'); ?>'     echo $after_title;     }


Get custom post type slug for an archive page

How do I discover the custom post type slug when I'm on an archive page? For instance if `/products/` fires the `archive-products.php` template, how (pragmatically) do I get the post type slug? Thanks


Would anyone happen to know why I keep getting the error: "The URL does not appear to reference a valid XML file. We encountered the following problem: Error on line 163: The entity "raquo" was referenced, but not declared." When I put CmChatLive.com into feedburner? http://feedburner.google.com/fb/a/addfeed I am unable to edit the output of that title entity.


Meta Box value not been pulled in

Here is the code that creates my metabox on my CPT named clients it displays fine and seems to keep the value input upon clicking update. The problem is with displaying the value saved within the metabox on a page. I've tried outputting the data both within a loop and out the loop switching between `get_the_ID() and $post_id` I've tried debugging with `<?php var_dump($link); ?>` which displays this on the frontend `string(0) ""` To output the meta box value in the loop I'm doing               // Get Meta data     $link = get_post_meta(get_the_ID(), 'link_url', true); ?>
<a href="<?php echo $link; ?>"><?php the_post_thumbnail('clients'); ?>
      Meta box Code               /**          * Adds a box to the main column on the Post and Page edit screens.          */         function portfolio_link_add_meta_box() {              $screens = array( 'clients' );              foreach ( $screens as $screen ) {                  add_meta_box(                 'portfolio_logo_link',                 __( 'Logo Link', 'logo_link_textdomain' ),                 'logo_link_meta_box_callback',                 $screen             );         }     }          add_action( 'add_meta_boxes', 'portfolio_link_add_meta_box' );          function logo_link_meta_box_callback( $post ) {              // Add an nonce field so we can check for it later.         wp_nonce_field( 'logo_link_meta_box', 'logo_link_meta_box_nonce' );              /*          * Use get_post_meta() to retrieve an existing value          * from the database and use the value for the form.          */         $value = get_post_meta( $post->ID, 'link_url', true );              echo '';         _e( 'Add The Logo Link', 'link_logo_textdomain' );         echo ' ';         echo '<input type="text" id="link" name="link" value="' . $value . '" size="25" />';     }          /**      * When the post is saved, saves our custom data.      *      * @param int $post_id The ID of the post being saved.      */     function logo_link_save_meta_box_data( $post_id ) {              /*          * We need to verify this came from our screen and with proper authorization,          * because the save_post action can be triggered at other times.          */              // Check if our nonce is set.         if ( ! isset( $_POST['logo_link_meta_box_nonce'] ) ) {             return;         }              // Verify that the nonce is valid.         if ( ! wp_verify_nonce( $_POST['logo_link_meta_box_nonce'], 'logo_link_meta_box' ) ) {             return;         }              // If this is an autosave, our form has not been submitted, so we don't want to do anything.         if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {             return;         }              // Check the user's permissions.         if ( isset( $_POST['post_type'] ) && 'page' == $_POST['post_type'] ) {                  if ( ! current_user_can( 'edit_page', $post_id ) ) {                 return;             }              } else {                  if ( ! current_user_can( 'edit_post', $post_id ) ) {                 return;             }         }              /* OK, it's safe for us to save the data now. */              // Make sure that it is set.         if ( ! isset( $_POST['link'] ) ) {             return;         }              // Sanitize user input.         $my_data = sanitize_text_field( $_POST['link'] );              // Update the meta field in the database.         update_post_meta( $post_id, 'link_url', $my_data );     }     add_action( 'save_post', 'logo_link_save_meta_box_data' );


How to run scripts when a new blog is created in Buddypress?

I'd like to insert some mysql data into every new blog that's created on my buddypress system. How can I hook up to the newly created blog data? ID, for example, would allow me to insert it right from the PHP. Is there a better way to do it? Thanks!


Include files in child themes, declare in functions.php

I'm using a child theme. I want to make a change to a file which currently resides in: > mybasetheme>includes>sf-content-display>sf-post-layouts.php So I copied the exact same file structure into my child theme and copied the file over: > mychildtheme>includes>sf-content-display>sf-post-layouts.php But it still defaults to the base theme version? Because it's in _includes_ I wondered if it was to do with the functions.php file calling it. So I created a new `functions.php` file in my child theme as follows:               <?php          // Functions specific to child-theme          require_once( get_stylesheet_directory() . '/includes/sf-content-display/sf-post-formats.php' );      But now I see that will never work as the base theme functions.php already calls it:               >include(SF_INCLUDES_PATH . '/sf-content-display/sf-post-formats.php');      So I get this error: > Cannot redeclare sf_get_post_media() (previously declared in > /Applications/MAMP/htdocs/syyco/wp-content/themes/flexform- > child/includes/sf-content-display/sf-post-formats.php:15) in > /Applications/MAMP/htdocs/syyco/wp-content/themes/flexform/includes/sf- > content-display/sf-post-formats.php on line 36 So what do I do? I can't make the child theme include my new file, without editing the base theme, which ruins the point of having a child theme at all


Using _e() on text inside video tags prints that text, instead of only showing when html5 <video> element is not supported

I'm creating a wordpress theme in which I'm creating a shortcode for a video. Part of the output of this shortcode is something like this:                  $result .= '<video class="fullWidth" width="auto" height="auto" loop muted preload>';         $result .= '<source src="'.$mp4.'" type="video/mp4" />';         $result .= '<source src="'.$webm.'" type="video/webm" />';         $result .= '<source src="'.$ogv.'" type="video/ogv" />';         $result .= _e('Video tag is not supported in your browser.', 'my-theme-framework');        $result .= '</video>';      Now the video is working but the text 'Vide tag is ...' is getting echoed out, but when I remove the text from the function, it gets hidden. So I believe it is because of the _e() function and I do not know what to do. I need that to make the text translation ready, should I remove it? I've searched around for this, but I'm getting no relevant results. Please tell me if you know what I should do here. Thank you.


Custom data retrieval through simple search

Ok, here is what I would like to do. I have three fields First name, Last name and date of birth I already created a table in wordpress db called nameSearch with those 3 fields I also imported all data through a csv import to mysql - to that table. I need a simple form that has simple search box for, say first name and a search button. When user clicks on Search button after putting in few characters or the entire full First Name, then matching result(s) should display in the page. It can either be displayed as table or inline text If some one can either explain the technique or share a simple piece of php code that would be awesome. Thank you so much you guys! PS: I understand programming, so feel free to be simple in answering. i just need to know how to do it in PHP/wordpress. Best wishes, Senthil


Using user_status in conditional with get_users to return existing users

I'm working on a plugin needing to return avatars a specific way. If the user exists in the wp_users table the code is run else a different set of code is run if the user is not in the wp_users table. I cannot use the username_exist and am tinkering now with the idea of using the user_status value of 0. From the Codex, code is possible to return information based on the user_status                       $blogusers = get_users('user_status=0');             foreach ($blogusers as $user) {                 echo '<li>' . $user->user_email . '</li>';             }      This returns the email address for the users in the wp_users table. But I want to use a conditional ... The following works on a local development server in which $id is 1. But not everyone using the plugin will have just this one user id ...                       if ( $id == '1' ) {                   // echo 'User ID is ' . $id;                  // Do something here              } else {                  // the user is not in WordPress do something cool                 }      How can I use the user_status in a conditional to check if the user_status is 0 then do something else run the code the user not being in the WP users table. In other words, how can I write a conditional to check user_status = 0?


Redirect loop when forwarding to mobile site

I have successfully redirected my page to _m.example.com_ from _example.com_ when i open in mobile environment with this code in _functions.php_               add_action('template_redirect', 'redirecting_to_mobile_site');     function redirecting_to_mobile_site(){     $requri = $_SERVER['REQUEST_URI'];           if( wp_is_mobile() )      {       $redcont = "http://m.example.com".$requri;       wp_redirect( $redcont, 301 ); exit;      }     }      I also created a sub-domain through WP sub-domain plugin. But when I click any link from index page it says " **This page has redirect loop** " Please advise how to enable sub-domain for internal pages. Thank you.


Custom Login iframe doesn't work

I have a custom login window that I am building. The client requires a modal window for the login, so I have to use HTTP (for performance) for the regular page, and HTTPS for the login window (in the iframe for security), because of this, I get the error: > Refused to display 'https://www.wordpress.com/wp-login.php' in a frame > because it set 'X-Frame-Options' to 'SAMEORIGIN'. I'm sure that this is a security feature so people can't iframe the wp- login.php page, but I want to remove it so this login will work properly. Is there anyway to remove the `'SAMEORIGIN' protection` for the wp-login.php page? Any help will be greatly appreciated.


Add custom class to a tags

I want to create a plugin that adds specific class to all a tags.


some posts being displayed as pages

Some posts I make (in the same category) are acting as pages, they open as page templates. I have the following in my `single.php`
                <?php           while (have_posts()): the_post();           $more = 0;              // the_title();              the_content('READ MORE');           endwhile;           ?>
       and `page.php`
                 <?php                  while (have_posts()): the_post();           $more = 0;              // the_title();              the_content('READ MORE');           endwhile;                  ?>
       Any idea why?


MySql Query very slow

I have a problem with a query on my website. When I load the page it is incredibly slow and only after over 12 seconds the content starts showing. I have installed a debug plugin and found the query that takes so long. The output of the plugin is the following:      > Time: 12,315.2ms (12.315196037292s) Query:               SELECT SQL_CALC_FOUND_ROWS meruca_posts.ID      FROM meruca_posts      WHERE 1=1      AND (         meruca_posts.ID NOT IN (             SELECT object_id             FROM meruca_term_relationships             WHERE term_taxonomy_id IN (14)         )     )     AND meruca_posts.post_type = 'post'      AND (         meruca_posts.post_status = 'publish'          OR meruca_posts.post_status = 'private'     )     GROUP BY meruca_posts.ID ORDER BY meruca_posts.post_date DESC LIMIT 0, 10      Function: `WP_Query->get_posts()` (`meruca_` is my table prefix) I have only basic understanding of mysql and can't really see, what may cause this to take so long. If anybody has an idea what I could change it would be much appreciated. There are about 5k posts on the site right now which isn't too many and it is running on a dedicated server that should have much more than sufficient resourced for any query theoretically.


Need some help with tweaking a code for woocommerce

I have this code to show custom text in the categories i choose.               <?php if (is_product_category('furnitures')) : ?>
This is the text to describe category A
     <?php elseif (is_product_category('kitchen')) : ?>
This is the text to describe category B
     <?php else : ?>
This is some generic text to describe all other category pages,      I could be left blank
     <?php endif; ?>      How can i make the text to also be shown in the subcategories of each parent. In the above code are "furnitures" and "kitchen" the parent and have some subcategories. Thanks!


Getting an alphabetic post list with two letters onclick on letter

I have a website in `Wordpress` and a page with a list with letters like this:               A B C D E F G H I ...      This shows me all posts with the letter A for instance. That's nice, but I want it to make it easier for my users, so I want to get `Ab` and all of the posts starting with Ab if I click on `A`, beneath this list. Another example: I want to get `Dc` and all of the posts starting with the letters Dc if I click on `D`. I know that this is possible by making 26 pages containing the letters and the functions, but there must be a simpler way to do this. Besides, I don't want 26 pages for such a simple thing. It would affect the `SEO`. Can someone help me out with this?


keep two blogs under the same domain

I am thinking about starting a self hosted wordpress blog. Currently, I own a blogger blog, written in portuguese. I'd like to have a blog about technology written in english at a domain, like http://example.com, and my old portuguese blog transfered to http://example.com/portugueseblog or something like this. From what I've gathered, it's possible to import blogger blogs to wordpress. But how do I import it to this specific url, while still being able to write in the main blog? Thanks in advance.


Find only those galleries with images

Is there a way in Wordpress to use WP_Query and retrieve posts/galleries that have more than 0 metavalues with the key _gallery_image_ids. Essentially I don't want to display galleries that have no images.


How to use this $tax_selection variable in this custom loop?

I took this code from this question (which shows how to let users choose which posts to display by choosing categories and tags): Filter index page plugin **function.php**               add_action( 'pre_get_posts', 'do_user_post_selection' );          function do_user_post_selection( $query ) {              if( !is_home() || !is_user_logged_in() )             return;              if( isset( $query->query_vars['post_type'] ) && ( 'nav_menu_item' == $query->query_vars['post_type'] ) )             return;          if( 1 < did_action('wp') )             return;         global $current_user;              $tax_selection = get_user_option( 'taxonomy_selection', $current_user->ID );              if( empty( $tax_selection ) )             return;              if( isset( $tax_selection['categories'] ) && ( is_array( $tax_selection['categories'] ) ) && ( !empty( $tax_selection['categories'] ) ) )              $query->set( 'category__in', $tax_selection['categories'] );         if( isset( $tax_selection['post_tag'] ) && ( is_array( $tax_selection['post_tag'] ) ) && ( !empty( $tax_selection['post_tag'] ) ) )              $query->set( 'tag__in', $tax_selection['post_tag'] );              return;     }      I have the following in the template of my front page: **front-page.php**                     <?php // Create and run custom loop               $custom_posts = new WP_Query();               $custom_posts->query('post_type=topic&posts_per_page=5');               while ($custom_posts->have_posts()) : $custom_posts->the_post();           ?>  <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>

<a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyeleven' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?>

             <?php endwhile; ?>
      How to use the value in `$tax_selection` in my custom loop?


How to Keep footer link remain intact?

I'm a Wordpress Theme Designer. I want to have functions to make my footer links remain intact. Like some themes that use this method to protect their footer link from the theme downloaders to remove it. If they alter, change, or deltete parts or all, they will get an error! Any step by step guide or source would really appreciated! Thanks so much! Regards, Thy


How to insert images into posts without using Add Media dialog

I want to simplify the process of inserting images when editing posts. In wordpress default, you have to click "Add Media" to show a popup dialog, upload images, choose from gallery.. it is too complicated. My desired process is:   1. Click "Add Image" to show a dialog   2. Click "Choose File" and pick an image from your computer   3. Click "Upload" and wait for the file to be uploaded. Then image is inserted into post automatically As an example, my desired process is just like the insert image button in the wordpress.stackoverflow.com rich text editor, you can click to see it (Sorry but I am not allowed to post images here) I know stackoverflow upload images to a third party provider, but I want to use my own wordpress installation. Also, I don't care the Media management section (wp-admin/upload.php), I probably will remove it from admin panel. My question is: How can I implement a simplified upload images process in Wordpress? Any plugin available?


Show uploaded images in full size

I have a very simple template where I am showing images. The code looks like this:               <?php      /*     * Template Name: Portfolio     */      ?>           <?php get_header(); ?>

                  <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>                  <?php                   the_content();                  ?>                  <?php endwhile; else: ?>
<?php _e('Sorry, no posts matched your criteria.'); ?>
             <?php endif; ?>

            <?php get_footer(); ?>      The problem is that when I upload my images in the editor, they become much smaller than they actually are (on the page). I control their size by setting `max-width: 100%` in my css already, so I don't want WordPress to limit the size. How can I remove this?


What's the right way to share data between widgets?

I've got a few custom widgets in my site, which I'm targeting to specific tags. There may be a case where there may be an overlap in widget targeting, and the desirable behaviour may be to only show the first of the widgets that match to that section or tag. Therefore, when a match occurs and the widget is to be displayed, I need to set a variable to indicate to the other widgets that are in that 'set' not to display anything. The obvious, but hacky, way to do this would be with a global variable, but this feels wrong. So I am hoping the Gods of Wordpress have a proper WP way to do it. Am I right?


wp_logout_url($redirect) won't logout and redirect ()

Even that I got the code from the wp docs               <a href="<?php echo wp_logout_url( get_permalink() ); ?>" title="Logout">Logout      This is the output when user clicks on it:               Warning: Cannot modify header information - headers already sent by (output started at /usr/home/nakashitabcn.com/web/pedidos/wp-content/themes/nakashita/functions.php:226) in /usr/home/nakashitabcn.com/web/pedidos/wp-login.php on line 368          Warning: Cannot modify header information - headers already sent by (output started at /usr/home/nakashitabcn.com/web/pedidos/wp-content/themes/nakashita/functions.php:226) in /usr/home/nakashitabcn.com/web/pedidos/wp-login.php on line 380          Warning: Cannot modify header information - headers already sent by (output started at /usr/home/nakashitabcn.com/web/pedidos/wp-content/themes/nakashita/functions.php:226) in /usr/home/nakashitabcn.com/web/pedidos/wp-includes/pluggable.php on line 697          Warning: Cannot modify header information - headers already sent by (output started at /usr/home/nakashitabcn.com/web/pedidos/wp-content/themes/nakashita/functions.php:226) in /usr/home/nakashitabcn.com/web/pedidos/wp-includes/pluggable.php on line 698          Warning: Cannot modify header information - headers already sent by (output started at /usr/home/nakashitabcn.com/web/pedidos/wp-content/themes/nakashita/functions.php:226) in /usr/home/nakashitabcn.com/web/pedidos/wp-includes/pluggable.php on line 699          Warning: Cannot modify header information - headers already sent by (output started at /usr/home/nakashitabcn.com/web/pedidos/wp-content/themes/nakashita/functions.php:226) in /usr/home/nakashitabcn.com/web/pedidos/wp-includes/pluggable.php on line 700          Warning: Cannot modify header information - headers already sent by (output started at /usr/home/nakashitabcn.com/web/pedidos/wp-content/themes/nakashita/functions.php:226) in /usr/home/nakashitabcn.com/web/pedidos/wp-includes/pluggable.php on line 701          Warning: Cannot modify header information - headers already sent by (output started at /usr/home/nakashitabcn.com/web/pedidos/wp-content/themes/nakashita/functions.php:226) in /usr/home/nakashitabcn.com/web/pedidos/wp-includes/pluggable.php on line 702          Warning: Cannot modify header information - headers already sent by (output started at /usr/home/nakashitabcn.com/web/pedidos/wp-content/themes/nakashita/functions.php:226) in /usr/home/nakashitabcn.com/web/pedidos/wp-includes/pluggable.php on line 705          Warning: Cannot modify header information - headers already sent by (output started at /usr/home/nakashitabcn.com/web/pedidos/wp-content/themes/nakashita/functions.php:226) in /usr/home/nakashitabcn.com/web/pedidos/wp-includes/pluggable.php on line 706          Warning: Cannot modify header information - headers already sent by (output started at /usr/home/nakashitabcn.com/web/pedidos/wp-content/themes/nakashita/functions.php:226) in /usr/home/nakashitabcn.com/web/pedidos/wp-includes/pluggable.php on line 707          Warning: Cannot modify header information - headers already sent by (output started at /usr/home/nakashitabcn.com/web/pedidos/wp-content/themes/nakashita/functions.php:226) in /usr/home/nakashitabcn.com/web/pedidos/wp-includes/pluggable.php on line 708          Warning: Cannot modify header information - headers already sent by (output started at /usr/home/nakashitabcn.com/web/pedidos/wp-content/themes/nakashita/functions.php:226) in /usr/home/nakashitabcn.com/web/pedidos/wp-includes/pluggable.php on line 711          Warning: Cannot modify header information - headers already sent by (output started at /usr/home/nakashitabcn.com/web/pedidos/wp-content/themes/nakashita/functions.php:226) in /usr/home/nakashitabcn.com/web/pedidos/wp-includes/pluggable.php on line 712          Warning: Cannot modify header information - headers already sent by (output started at /usr/home/nakashitabcn.com/web/pedidos/wp-content/themes/nakashita/functions.php:226) in /usr/home/nakashitabcn.com/web/pedidos/wp-includes/pluggable.php on line 713          Warning: Cannot modify header information - headers already sent by (output started at /usr/home/nakashitabcn.com/web/pedidos/wp-content/themes/nakashita/functions.php:226) in /usr/home/nakashitabcn.com/web/pedidos/wp-includes/pluggable.php on line 714          Warning: Cannot modify header information - headers already sent by (output started at /usr/home/nakashitabcn.com/web/pedidos/wp-content/themes/nakashita/functions.php:226) in /usr/home/nakashitabcn.com/web/pedidos/wp-includes/pluggable.php on line 876      Being the URL something like:               http://website.com/pedidos/wp-login.php?action=logout&redirect_to=http%3A%2F%2Fwebsite.com%2Fpedidos%2F&_wpnonce=db999bfbcb      -EDIT-               function remove_admin_bar() {         global $wp_admin_bar;         if (is_user_logged_in()) {             if (!current_user_can('administrator') && !is_admin()) {               show_admin_bar(false);     /* LINE 226*/         echo '';             }              }     }


How to customize a title by passing query string?

I have a profile page, it is a template. Every time when I click one of a doctor, the profile page will show the specific doctor info by passing a query string. Something like profile?doctorName=abc. I have rewrote to profile/abc. Now the page title is "profile | blog name", But I would like to change the title to "abc(doctor's name) | hospital name".(Different doctor is in different hospital). This is my code below, and I tried to put it in the function.php and the profile template:                  <title><?php if (is_page( physician_single_pg()))                {                 echo something               ////How to get the doctor name                 echo " | ".(our_doctors()); //the hospital name, get from the plugin                                }               else                 {                 wp_title( '|', true, 'right' );                 }               ?>         </title>      I am thinking maybe I can push the query string to the plugin and pull it out in the header. But I don't know how to do that. I didn't get any luck. Please help, every suggestion is welcome. Thank you.


Page Templates - this code only works for one Custom Post Type

I have the code below in my functions.php file, it works great and allows me to use page templates in my custom post type 'services'. I have defined which 'type' to use on the first line with 'services'.               define('MY_CUSTOM_POST_TYPE', 'services');      The problem is I have multiple custom post types. I want to use the function allow me to choose page templates for ALL my custom post types. Being a complete novice I can't get it to work. Here is the code in full:               # Define your custom post type string     define('MY_CUSTOM_POST_TYPE', 'services');          /**      * Register the meta box      */     add_action('add_meta_boxes', 'page_templates_dropdown_metabox');     function page_templates_dropdown_metabox(){         add_meta_box(             MY_CUSTOM_POST_TYPE.'-page-template',             __('Template', 'my_template'),             'render_page_template_dropdown_metabox',             MY_CUSTOM_POST_TYPE,             'side', #I prefer placement under the post actions meta box             'low'         );     }          /**      * Render your metabox - This code is similar to what is rendered on the page post type      * @return void      */     function render_page_template_dropdown_metabox(){         global $post;         $template = get_post_meta($post->ID, '_wp_page_template', true);         echo "             <label class='screen-reader-text' for='page_template'>Page Template</label>                 <select name='_wp_page_template' id='page_template'>                 <option value='default'>Default Template</option>";                 page_template_dropdown($template);         echo "</select>";     }          /**      * Save the page template      * @return void      */     function save_page_template($post_id){              # Skip the auto saves         if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )             return;         elseif ( defined( 'DOING_AJAX' ) && DOING_AJAX )             return;         elseif ( defined( 'DOING_CRON' ) && DOING_CRON )             return;              # Only update the page template meta if we are on our specific post type         elseif(MY_CUSTOM_POST_TYPE === $_POST['post_type'])             update_post_meta($post_id, '_wp_page_template', esc_attr($_POST['_wp_page_template']));     }     add_action('save_post', 'save_page_template');               /**      * Set the page template      * @param string $template The determined template from the WordPress brain      * @return string $template Full path to predefined or custom page template      */     function set_page_template($template){         global $post;         if(MY_CUSTOM_POST_TYPE === $post->post_type){             $custom_template = get_post_meta($post->ID, '_wp_page_template', true);             if($custom_template)                 #since our dropdown only gives the basename, use the locate_template() function to easily find the full path                 return locate_template($custom_template);         }         return $template;     }     add_filter('single_template', 'set_page_template');


Exposing custom fields to the user in custom type post

I have a custom post type - say Hotel Booking - all the data are filled in by the admin and users can browse through different Hotel Rooms. Now, I would like the user to be able to tick additional options before they book which will increase the final price. So for example the user can tick 'Additional Meal' and the price would update or 'Insurance' - the price will update. All of this in the frontend - not in custom-type edit page. I am not sure how to do this I know that that in Drupal the fields can be exposed to be selectable/changeable by the user. Is there a way to do this easily in Wordpress?


Retrieve only posts from a specific user in wp-admin/edit.php

I create a role and set capabilities for a group of user.               $userdata = array(         //something     );     $uid = wp_insert_user($userdata);     if(!empty($uid)){         $blogger = new WP_User($uid);         //add role         $capabilities =  array(             'read' => true,             'publish_posts' => true,             'edit_published_posts' => true,             'delete_published_posts' => true,             'edit_posts' => true,             'delete_posts' => true         );         add_role('blogger_simple', 'blogger_simple', $capabilities);         $blogger -> set_role('blogger_simple');     }      Now, the user create successfully. I logged in to the system, and create `one` post , just `one` post. Then I click the menu `Post --> All Posts` and found three columns there `Mine(number) All(number) Published(number)`. I click All(2), find I can see others posts?   I click Published(2), still 2 posts one is mine the other is by admin What's more, I search post, got the same results. That's not I want, I just want to get my posts not by admin and all other user's post. How do I get just my posts when I click `All/Published` link below `All posts` menu, and also the `search box`.


Embed Post in external page

I am wanting to create a page that can be embedded in other sites with an embed script like this:               <iframe src="http://www.mysite.com/the_hidden_page?setting=set1&setting2=set2"></iframe>      The page will need to be 'hidden' so it does not appear in the menu on my site and it will need to accept a query string. The URL in my example does not need to be exactly like this, something like '/the_hidden_page/set1/set2' would be fine as well.


How to transition cookies from .subdomain.domain.com to .domain.com with minimal impact on users?

I need to extend the cookies of a subdomain.domain.com to all of the domain.com's subdomains (.domain.com in cookie terms). I am trying to minimize the impact of this transition. It seems that flipping the switch with `define('COOKIE_DOMAIN', '.domain.com');` in wp-config leaves the user in a state of limbo -- their cookie is good enough to validate, so it won't move to the new domain scope. Any ideas on how I can transition cookies from .subdomain.domain.com to .domain.com with minimal impact on users? Here's the code I've been failing and flailing with. It attempts to validate the old cookies when a bad hash is detected (from changing `AUTH_KEY` in wp- config.php) and then tries to re-validate and send them back to where they came from:               function do_report_bad_hash( $cookie_elements ) {              if( isset( $_COOKIE['wordpress_logged_in_'] ) ) {             $user_id = wp_validate_auth_cookie( urldecode( $_COOKIE['wordpress_logged_in_']), 'logged_in' );                  setcookie( 'wordpress_logged_in_', '', 0, '/', '.subdomain.domain.com', false, true );              unset( $_COOKIE['wordpress_logged_in_'] );                  setcookie( 'wordpress_', '', 0, '/', '.subdomain.domain.com', false, true );              unset( $_COOKIE['wordpress_'] );                  if ( $user_id !== false ) {                      wp_set_auth_cookie($user_id);                      $redirect = ( strpos($_SERVER['REQUEST_URI'], '/options.php') && wp_get_referer() ) ? wp_get_referer() : $proto . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];                      header("Location: $redirect");                      }              }           }     add_action('auth_cookie_bad_hash', 'do_report_bad_hash', 11, 1 );


Featured posts and the loop

I'm trying to add a box in index.php where to show the latest 3 featured posts. According to this tutorial, I've added the following to **functions.php** :               add_theme_support( 'featured-content', array(         'filter'     => 'magdeleine_get_featured_posts',         'max_posts'  => 3,     ) );          function magdeleine_get_featured_posts() {         return apply_filters( 'magdeleine_get_featured_posts', array() );     }          function magdeleine_has_featured_posts( $minimum = 1 ) {         if ( is_paged() )             return false;              $minimum = absint( $minimum );         $featured_posts = apply_filters( 'magdeleine_get_featured_posts', array() );              if ( ! is_array( $featured_posts ) )             return false;              if ( $minimum > count( $featured_posts ) )             return false;              return true;     }      Then I've created a **featured.php** template like this:               <?php     // Get our Featured Content posts     $featured = magdeleine_get_featured_posts();          // If we have no posts, our work is done here     if ( empty( $featured ) )         return;          foreach ( $featured as $post ) : setup_postdata( $post );     ?>              [...post code...]          <?php endforeach; ?>     <?php wp_reset_postdata(); ?>      Last, I've called the template inside **index.php** this way:               <!-- Editor's picks -->     <?php if ( magdeleine_has_featured_posts( 1 ) ) : ?>         <?php get_template_part( 'featured' ); ?>     <?php endif; ?>                               <?php /* Start the Loop */ ?>     <?php while ( have_posts() ) : the_post(); ?>     ...      But... How to avoid repeating the same posts in the loop?


WP_Query to get all posts with specified category in priority

Now I have a query to get all posts in the specific category `featured`.               $today = date('Y-m-d');     $args = array(         'post_type'         => 'event',         'event-categories'  => 'featured',         'meta_key'          =>  '_event_end_date',           'meta_compare'      => '>',         'meta_value'        => $today,          'order'             =>  'DESC',         'posts_per_page'    => '10',     );          $query = new WP_Query( $args );      Instead of this I need a query to get all post for the event post type with featured category in priority(first list all events with featured category, then the remaining events) and then the other event with pagination.


WordPress it's cleaning a custom query_var to avoid sql injections?

I am using `get_query_var` function to get a custom `query_var`. This `query_var` will be used later in to query arguments to retrieve posts with:               $the_query = new WP_Query( $args ); .      My question is, is it safe if I use `get_query_var` such as is provided or do I need clean this variable to avoid sql injections? I've read this post, but it is not entirely clear and also it is old.


Wordpress tags as twitter sharer URL hastags

I want to share a wordpress post on twitter. I'm using this :               <a href="https://twitter.com/share?url=<?php the_permalink() ?>&text=<?php the_title() ?>&via=<?php the_author() ?>&hashtags=<?php the_tags('', '') ?>" >      My problem is that `the_tags()` prints the tags inside the `<a>` tag. How can I use `the_tags('', '')` ( which separates the tags with comma as the hashtag needs to be ) for twitter hashtags ? I would appreciate any solutions without the use of a plugin


Change header based on visitor choice

I need to show a different header file ("header-tourist.php" and "header- agent-php") based on a choice the visitor will make. For example, I have 2 main buttons: `View site as Tourist` or `View site as Agent`. Based on this, I would like to show a different header throughout the whole site. What is the best way to approach this (global variables, sessions etc.) ?