I am currently using the following code within single.php (after the_content) This gets the store_name from custom field as $merchant from the post and then returns a list of products from that merchant from and external script.  &lt;?php $merchant = get_field('store_name'); echo '&lt;h3&gt; Random products from ' . get_field('store_name') . '&lt;/h3&gt;'; $external_baseHREF = "http://www.website.com/store/"; $external_path = "/home/website/public_html/store/"; $_GET["q"] = "merchant:".$merchant; require($external_path."searchExternal.php"); ?&gt;       This is working fine, however I cannot move the position of where the products are appearing, they currently appear after the main post.  I would like to have them appearing further up the post, and one solution I have considered is adding them via a shortcode so I can position them as I like eg  [merchant-name merchantname="Adidas"] or something similar  Can you please assist in creating this shortcode? Or offering alternative solution.  Thanks Richard
121705
So I have the following code:   &lt;span class="delete"&gt;&lt;a onclick="return confirm('Are you sure?');" href="&lt;?php echo wp_nonce_url( add_query_arg( array( 'action' =&gt; 'my-delete-product', 'product_id' =&gt; $post-&gt;ID ), my_get_navigation_url('products') ), 'my-delete-product' ); ?&gt;"&gt;&lt;?php _e( '삭제', 'my' ); ?&gt;&lt;/a&gt; | &lt;/span&gt;   It is a simple button.  I want to make this into a shortcode so that I can use it anywhere where appropriate.  Any suggestions?  Thanks.
114273
I have a search field for the blog posts, but I need an other for a custom post type. How can I create this custom search form with a different search result layout?
99465
So i made a blog and I would like to put all the images in a post in a gallery/slider. I'm using the Enfold Child Theme so I looked up the gallery shortcode and made this function in the single.php(Single Post) where I get the image ids from a post and then I put them in the shortcode. The problem is, it doesn't show any images.. I Tried using the shortcode in a single post where I hardcoded the ids in the shortcode, and that worked perfectly. Anybody know what I'm doing wrong here or has a better solution? Thanks Single.php:  &lt;?php if (!function_exists('get_associated_media')) {      function get_associated_media($post_id) {         $attachmentIds = array();         $media = get_children(array(             'post_type' =&gt; 'attachment',             'post_parent' =&gt; $post_id,             'post_status' =&gt; 'inherit',             'post_mime_type' =&gt; array('image/jpeg', 'image/gif', 'image/png'),             'numberposts' =&gt; -1         ));          foreach ($media as $file) {             $attachmentIds[] = $file-&gt;ID;         }         $attachmentIds[] = get_post_thumbnail_id($post_id);         echo do_shortcode('[av_gallery ids=&quot;' . implode(&quot;,&quot;, $attachmentIds) . '&quot; type=&quot;slideshow&quot; style=&quot;big_thumb&quot; preview_size=&quot;portfolio&quot; crop_big_preview_thumbnail=&quot;avia-gallery-big-crop-thumb&quot; thumb_size=&quot;portfolio&quot; columns=&quot;5&quot; imagelink=&quot;lightbox&quot; lazyload=&quot;avia_lazyload&quot; av_uid=&quot;av-jgesnq4m&quot; custom_class=&quot;av-gallery-style-&quot;]');         return array_unique($attachmentIds);     } }  ?&gt;
20150
When using data.stackexchange.com I fail to remember if as [post link] is the correct alias to get the url for the post. Luckily the site has an  link. Unfortunately it is now broken. Can this be fixed?
42692
I created an entity via Entity Construction Kit, Initially I wanted to use rules to create the new entity but the entity is fielded and the fields don't get exposed in rules (as of now, someone is trying to work on a patch for that), but in the interm I wanted to write a simple function that creates a entity, which I assumed would be somewhat like creating a node programmatically, but I've been at this for like 4 hours and I haven't gained an inch, I have entity_create and entity_save but they don't do much and I can't find any documentation on it.  What I'd like to see is how to create an example entity from a bundle made with eck, or through code, that is fielded.  Thanks so much  Edit: The last thing I need to figure out is how to specify the name of the fields that are attached to the entity so I can enter values for those as well.  $values = array('uid' =&gt; 1, 'field_receipt_prod_ref' =&gt; 1, 'type' =&gt; 'receipt');         $new_ent = entity_create('receipt', $values)-&gt;save();
97965
I'm using field_info_instances() to retrieve the information for all the fields used by a content type, for example calling it as field_info_instances('node','bundle_name'). In the returned array, the fields aren't ordered as I expected. I need to get the fields ordered per weight. For example, a field weight is 8, in the Manage fields list.    Despite this, it's shown on the top, in the output from field_info_instances().    Is there any possibility to get the fields ordered?
112662
echo $_POST["name"]; //returns the value a user typed into the "name" field   I would like to be able to also return the text of the key. In this example, I want to return the text "name". Can I do this?
6971
I have a view and added the title as a field. For example: How do I print the title?  In Drupal 7 it was as simple as views-view-fields--[viewname].tpl.php &lt;?php print $fields[&quot;title&quot;]-&gt;content; ?&gt;   How do we do this in Drupal 8? I have created views-view-fields--[viewname].html.twig I thought it might be {{ fields.title }} but I get the classic error message like so:  The website encountered an unexpected error. Please try again later.  I then tried {{ field.title }}, {{ title }} and {{ content.title }} but nothing prints.
114845
Consider in my basket, I have a package (Main Product-just a holder) which will have 2 standalone products (child) and again the standalone products will have child products (Grand Parent). All these products are from same object called Product Configuration.   We have a child relationship to itself(Parent Configuration) using a custom lookup field. The problem here is, I could only fetch details only up to 1 level (i.e.,package and child details) and I was not able to drill deeper to grand child products.  Query I used to get 1 level of relation ships is below:  SELECT id, name, Access_Type__c, Circuit_Bandwidth_Value__c, QuoteType__c,     Upstream_Speed_Value__c, IP_Address_Type__c, Care_Level__c, Base_Plan_Value__c, Site_Address__c,      cscfga__Quantity__c, Quantity_of_Ip_Address__c, cscfga__Contract_Term__c, Connection_Price__c,      Monthly_Rental_Conga__c, Total_Annual_Rental__c,      (         SELECT id, name,cscfga__Product_Family__c,Upstream_Speed_Value__c, cscfga__Quantity__c, Quantity_of_Ip_Address__c,              Connection_Price__c, Monthly_Rental_Conga__c,cscfga__Parent_Configuration__r.Circuit_Bandwidth_Value__c,Circuit_Bandwidth_Value__c          FROM cscfga__Related_Configurations__r         WHERE cscfga__Parent_Configuration__c &lt;&gt; ''          ORDER BY name     )  FROM cscfga__Product_Configuration__c  WHERE cscfga__Product_Basket__r.cscfga__Opportunity__c='{pv0}'      AND cscfga__Product_Basket__r.csordtelcoa__Synchronised_with_Opportunity__c=True     AND cscfga__Parent_Configuration__c = ''  ORDER BY name   Not sure how to write another sub query to get grand child details. When I tried the below query:  SELECT id, name, Access_Type__c, Circuit_Bandwidth_Value__c, QuoteType__c, Upstream_Speed_Value__c,      IP_Address_Type__c, Care_Level__c, Base_Plan_Value__c, Site_Address__c, cscfga__Quantity__c,      Quantity_of_Ip_Address__c, cscfga__Contract_Term__c, Connection_Price__c,      Monthly_Rental_Conga__c, Total_Annual_Rental__c,     (         SELECT id, name, cscfga__Product_Family__c, Upstream_Speed_Value__c, cscfga__Quantity__c,              Quantity_of_Ip_Address__c, Connection_Price__c, Monthly_Rental_Conga__c, cscfga__Parent_Configuration__r.Circuit_Bandwidth_Value__c, Circuit_Bandwidth_Value__c,         FROM cscfga__Related_Configurations__r         WHERE cscfga__Parent_Configuration__c &lt;&gt; ''          ORDER BY name     ),     (         SELECT id, name, cscfga__Product_Family__c          FROM cscfga__Related_Configurations__r         WHERE cscfga__Parent_Configuration__c &lt;&gt; ''          ORDER BY name     ) FROM cscfga__Product_Configuration__c  WHERE cscfga__Product_Basket__r.cscfga__Opportunity__c='0066E000002Xrr0'      AND cscfga__Product_Basket__r.csordtelcoa__Synchronised_with_Opportunity__c=True      AND cscfga__Parent_Configuration__c = ''  ORDER BY name   I got below error:     MALFORMED_QUERY:  from cscfga__Related_Configurations__r ^ ERROR at   Row:6:Column:6 Cannot follow the same aggregate relationship twice:   cscfga__Related_Configurations__r   Can someone please help here. Note: I am executing these queries in Workbench.
69575
In Drupal 7, is there a way to add more fields to the registration process? I was thinking along the lines of birthday, fullname, gender, twitter, etc. Also how do I access this data once it's in, so I can output it to my template files?
32134
I'm using a SOQL to query the lookup relationships.  Primary Object: Opportunity  Secondary Object: Purchase__c.  From purchase__c we have a lookup to opportunity.  Field Name: Opportunity__c  Child Relationship Name: Purchases2  SOQL query:  for (Opportunity opp : [select Id, Name, (select id from Purchases2__r where Count__c&gt;0) from Opportunity where Id IN :oppIds])    whats wrong with my query? getting error below:     If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name.
65517
I would like to ask that what code should i add in order to make my related posts by tag to display randomly? I got this code from somewhere else.  &lt;?php $orig_post = $post; global $post; $tags = wp_get_post_tags($post-&gt;ID); if ($tags) { $tag_ids = array(); foreach($tags as $individual_tag) $tag_ids[] = $individual_tag-&gt;term_id; $args=array( 'tag__in' =&gt; $tag_ids, 'post__not_in' =&gt; array($post-&gt;ID), 'posts_per_page'=&gt;5, // Number of related posts that will be shown. 'caller_get_posts'=&gt;1 ); $my_query = new wp_query( $args ); if( $my_query-&gt;have_posts() ) { echo '&lt;div id="related"&gt;&lt;h4&gt;Related Posts&lt;/h4&gt;'; while( $my_query-&gt;have_posts() ) { $my_query-&gt;the_post(); ?&gt; &lt;div class="ncc"&gt; &lt;h5&gt;&lt;a href="&lt;? the_permalink()?&gt;" rel="bookmark" title="&lt;?php the_title(); ?&gt;" rel="nofollow"&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt;&lt;/h5&gt; &lt;?php the_excerpt(); ?&gt;  &lt;/div&gt;&lt;!--ncc--&gt;  &lt;? } echo '&lt;/div&gt;&lt;!--related--&gt;'; } } $post = $orig_post; wp_reset_query(); ?&gt;   Any solution? Thanks!
107747
Please bear with me because I am new to utilizing Wordpress PHP this way. I have the following script:  &lt;div id="content"&gt; &lt;?php     // check if the repeater field has rows of data     if( have_rows('repeat_field') ):         $i = 0;          // loop through the rows of data         while ( have_rows('repeat_field') ) : the_row();             $i++;              // display a sub field value             if (!empty(get_sub_field('feature_image_post'))) {                  echo '&lt;a href="';                 the_sub_field('restaurant_article_link');                  echo '"&gt;';             }              if( $i &gt;= 78 ) {                 break;             }                     endwhile;     else :         // no rows found     endif;     ?&gt;     &lt;/div&gt;     &lt;div id="loading-image" style="display: none;"&gt;&lt;/div&gt;     &lt;div id="part2"&gt;&lt;/div&gt;     &lt;script&gt;          var w = $(window);         window.onscroll = function(ev) {             if ($(document).height() - w.height() == w.scrollTop()) {                  $('#loading-image').show();                 $.ajax({                     url: "&lt;?php echo get_stylesheet_directory_uri();?&gt;/post-2.php",                     cache: false,                     success: function(result){                       $("#part2").html(result);                     },                     complete: function(){                       $('#loading-image').hide();                     }                 });             }         };     &lt;/script&gt;   The the Php page that I am trying to load pretty much contains the same code . It just stops after loading 200 fields.   &lt;?php     // check if the repeater field has rows of data     if( have_rows('repeat_field') ):         $i = 0;         // loop through the rows of data         while ( have_rows('repeat_field') ) : the_row();             $i++;             // display a sub field value             if (!empty(get_sub_field('feature_image_post'))) {                 echo '&lt;a href="';                 the_sub_field('restaurant_article_link');                  echo '"&gt;';             }              if( $i &gt;= 200 ){               break;             }                      endwhile;     else :         // no rows found     endif; ?&gt;   I don't know why the php page (post-2.php) is not loading. The strange thing is that when I replace &lt;?php echo get_stylesheet_directory_uri();?&gt;/post-2.php with a test html page &lt;?php echo get_stylesheet_directory_uri();?&gt;/test.html The test page (test.html) loads.  I have to say that I looked on in my console using the console tab of my browser added console.log(); to view any errors and I'm not getting any errors. I also looked in my networked tag to ensure that post-2.php loaded properly and I'm not getting errors. My goal is to find out why my PHP page isn't loading  ***** Update ***** I'm being told to use $post_id but I've never used it. Does anyone have a working example of this? Would it be similar to if( have_rows('repeat_field', $post_id) ): or if( have_rows('repeat_field', 55612) ): ?
74939
Here's my issue. I have a custom post type that I'm attaching a custom taxonomy to. This taxonomy will allow the admin to provide search suggestions that will ensure the post is found when a user searches. This taxonomy is also used on the front-end to autocomplete the search field with these suggestions.  The system works fine, except when the term contains a forward slash, a space or other "special" characters.  &lt;?php $keyword = 'Ski-in%2FSki-out';//Submitted via $_GET $keyword = urldecode($keyword); // (string)'Ski-in/Ski-out'  $taxQuery = new WP_Query(array(     'post_type' =&gt; 'ml_properties',     'tax_query' =&gt; array(         'relation' =&gt; 'OR',         array(             'taxonomy' =&gt; 'mc_tax_lifestyle',             'field' =&gt; 'name',             'terms' =&gt; array($keyword),             'operator' =&gt; 'IN'         )     ) )); ?&gt;   I've looked into using the escaping features provided by WordPress, but haven't had any luck there. I thought this would be a simple problem, but either my Google-fu is not strong, or I'm just not having any luck.  I've also verified that that Ski-in/Ski-out is the exact string stored in MySQL. I've looked into using esc_attr(), $wpdb-&gt;esc_like() and esc_sql() but none have an effect.  Perhaps I'm missing something obvious?
2798
I'm looking for a library that has functionality similar to Perl's , but for PHP. Basically, it should allow me to submit HTTP GET and POST requests with a simple syntax, and then parse the resulting page and return in a simple format all forms and their fields, along with all links on the page.  I know about CURL, but it's a little too barebones, and the syntax is pretty ugly (tons of curl_foo($curl_handle, ...) statements  Clarification:  I want something more high-level than the answers so far. For example, in Perl, you could do something like:  # navigate to the main page $mech-&gt;get( 'http://www.somesite.com/' );   # follow a link that contains the text 'download this' $mech-&gt;follow_link( text_regex =&gt; qr/download this/i );  # submit a POST form, to log into the site $mech-&gt;submit_form(     with_fields      =&gt; {         username    =&gt; 'mungo',         password    =&gt; 'lost-and-alone',     } );  # save the results as a file $mech-&gt;save_content('somefile.zip');   To do the same thing using HTTP_Client or wget or CURL would be a lot of work, I'd have to manually parse the pages to find the links, find the form URL, extract all the hidden fields, and so on. The reason I'm asking for a PHP solution is that I have no experience with Perl, and I could probably build what I need with a lot of work, but it would be much quicker if I could do the above in PHP.
114332
I have the problem, that PHP replaces all spaces with underscores in POST and GET variables. For example if I have the URL: http://localhost/proxy.php?user name=Max the browser will convert it to http://localhost/proxy.php?user%20name=Max. But if I give the $_GET parameters out, the key is not user name but user_name (note the underscore)! Is there any possibility to change this behaviour?
83828
It's got to be somewhere in the phpinfo() dump, but I just don't know where.  Is it supposed to be under the "Additional Modules" section?  Somewhere else?  I'm trying to figure out why some extensions don't appear to be loaded, but I don't even know where I should be looking.