How do you output custom code before a subset of posts in the loop?

I have a foreach loop for a custom post type ordered by date (meta key). If a post’s associated date is less than the current date (i.e., dates not in the future), I want to output some HTML. if ($ custom_post_date >= $ today && $ index === 1) The problem I am running into is that the HTML gets output after the first post that is in the past. How can I output the HTML before the first post that meets the criteria? Is there a way to go back in the foreach loop or something to that effect?

Save the post parent in a custom post type in Gutenberg

A plugin I’m developing registers two custom post types: Class and Student. Both are connected via the post_parent property in the Student post type (one student belongs to one class). I added a SelectControl control to the PluginDocumentSettingPanel in the Student post type edit screen to be able to set a Class for the Student. Everything is working except the saving part. The changes are not saved. Any ideas?

Thanks in advance

const { __ } = wp.i18n; const { compose } = wp.compose; const { registerPlugin } = wp.plugins; const { SelectControl } = wp.components; const { PluginDocumentSettingPanel } = wp.editPost; const { withSelect, withDispatch } = wp.data;  const applyWithSelect = withSelect( ( select ) => {     const {         getEditedPostAttribute,         getCurrentPostType     } = select( 'core/editor' );     const {         getEntityRecords     } = select( 'core' );      const parent = getEditedPostAttribute( 'parent' );      const posts = getEntityRecords( 'postType', 'class', { per_page: -1, orderby: 'title', order: 'asc', _fields: 'id,title' } )      return {         currentPostType: getCurrentPostType(),         parent: parent,         posts: posts     }; } );  const applyWithDispatch = withDispatch( ( dispatch ) => {     const { editPost } = dispatch( 'core/editor' );      return {         onUpdateParent( value ) {             editPost( { parent: Number( value ) } );         },     }; } );  function StudentOptionsPanelComponent( {     // These props are passed by applyWithSelect().     currentPostType, // current post type     parent, // current value of parent     posts, // all posts     // And these are passed by applyWithDispatch().     onUpdateParent,  // function which updates the meta restrict } ) {     if ( 'student' !== currentPostType ) {         return null;     }      if ( ! posts ) {         return __( 'Loading...', 'my-plugin' );     }      if ( posts.length === 0 ) {         return __( 'No classes found', 'my-plugin' );     }      var options = [];     options.push( {         label: __( 'Select a class...', 'my-plugin' ),         value: ''     } );      for ( var i = 0; i < posts.length; i++ ) {         options.push( {             label: posts[i].title.raw,             value: posts[i].id         } );     }      return (         <PluginDocumentSettingPanel             name='student-options'             title={ __( 'Options', 'my-plugin' ) }             className='student-options-panel'         >             <SelectControl                 label={ __( 'Select a class:', 'my-plugin' ) }                 value={ parent }                 options={ options }                 onChange={ onUpdateParent }             />         </PluginDocumentSettingPanel>     ); }  const StudentOptionsPanel = compose(     applyWithSelect,     applyWithDispatch )( StudentOptionsPanelComponent );  registerPlugin( 'student-options-panel', {     render: StudentOptionsPanel, } ); 

how can i set a custom header with javascript or php? [closed]

How can i set a custom header using javascript or php? I am trying to add a custom header to my html form but i’m new to programming so i’m still learning.

I’d like to add a custom header to my form and my current form code is this one:

<form> [set-custom-header] <input type="text" name="username" value=""> <input type="text" name="setterId" value=""> <input type="submit" value="send"> </form> 

I’d like to set a custom header on that form, what could i use? Is it possible to do that without using xhr?

Thanks,

How do I create a column and display user data from custom registration field

Our registration form has a custom field for Hospital Name. In SQL wp_usermeta the meta_key is user_registration_hospital. I have tested a number of snippets in the functions.php file to add a "Hospital" column to the Users admin table, all of which work. This is one of the snippets that adds the Hospital column:

function add_user_columns($  column) { $  column['hospital'] = 'Hospital';  return $  column; 

} add_filter( ‘manage_users_columns’, ‘add_user_columns’ );

What code do I need to add to the functions.php file to have the Hospital data from wp_usermeta populate the Hospital column?

Custom Taxonomy is Missing (Or Limiting) Items

I created a custom taxonomy; "places" using toolset

region>country>city with 12 Regions / All Countries and just a few cities; 12 parents, 260 children

Where I am using the taxonomy in a post, custom post type or the menu, only some of the items show and it is quite random. 1/2 of Europe shows up 3 from the Caribbean, etc

I used the plugin Toolset; this issue has repeated in 4 different installs. I have worked with hosting and they assure me it is a development issue. I have worked with toolset and am on Day 6 of no solution; I have tried with different themes (Hello & Astra), Using Elementor or not (no plugins other than toolset itself; there is no support over the weekend. Does anyone have any idea WHY I would be missing just some of the taxonomy?

I am not seeing any errors in debugging

Sort the result of the main Query in shop page by a custom taxonomy

In a WooCommerce site, we have products that have a custom taxonomy that are assign to a region.

When the user visits the site, we activate the browser geolocation, and we assign the user a region in a cookie.

Now we would like to show, in the shop page and in the product_cat taxonmies, in first the products that are assign to the same region of the user and then all other regions.

How could we implement this ?

So far, I taught of using pre_get_posts, and using something like :

add_action('pre_get_posts', 'order_by_region', 999999); function order_by_region($  q){  if(!is_admin() && $  q->is_main_query() && (is_shop() || is_tax('product_cat'))){   $  q->set('orderby', 'meta_value');   $  q->set('order', 'DESC');   $  q->set('value', $  _COOKIE['nameofusercookie']);   $  q->set('meta_key', 'regions');   }   return $  q; } 

But this didn’t work. I just found that in there it will filter the posts instead of ordering by regions.

I found the ‘the_posts’ hook. That contains all the products after quering but not yet looped. I think it might be better place to sort all the products with the cookie. But how do i compare the cookie and the regions taxonomy in each products ?

add_filter('the_posts', 'sort_query_by_region', 10, 2); function sort_query_by_region($  posts, $  q){  $  cookie = $  _COOKIE['selected_region'];   if(isset($  cookie) && !empty($  cookie)){   if(!is_admin() && $  q->is_main_query() && (is_shop() || is_tax('product_cat'))){    $  posts = sortByRegion($  posts);   }  }  return $  posts; }  function sortByRegion($  posts){  usort($  posts, "regionOrder");  return $  posts; }  function regionOrder($  a, $  b) {    // get the cookie    $  cookie = $  _COOKIE['slected_region'];    // Get the term region of each compared product   $  regionA = get_the_terms($  a->ID, 'regions')[0]->slug;   $  regionB = get_the_terms($  b->ID, 'regions')[0]->slug;    if($  regionA != $  cookie || $  regionB != $  cookie){    return ($  a, $  b);   } else {    return $  a < $  b;   } } 

I must that either doesn’t work.

Anyone everdone such a re-ordering and knows I to help me?

WordPress Custom Avatar in comments

I have built my own frontend user avatar upload script. Now the avatars show fine in the user section in admin and in the top panel. However I can’t seem to get them showing in the comments and author sections of the site.

I use the following get_avatar code

add_filter ('get_avatar', function($  avatar_html, $  id_or_email, $  size, $  default, $  alt) { $  avatar = get_user_meta($  id_or_email,'avatar',true); if( $  avatar ) {     return '<img src="'.$  avatar.'" width="96" height="96" alt="Avatar" class="img-fluid rounded-circle" id="wad_profile_avatar" />'; } else {     return $  avatar_html; } 

}, 10, 5);

Any ideas how I can get it to show in comments also?

Dedicated Private Proxies (from 0.8$) | Shared Proxies (from 0.25$) | Discounts | Custom GEO | Bulk

Selling Dedicated Private Proxies (from 0.8$ ) | Shared Proxies (from 0.25$ ) | Discounts | Custom GEO | Bulk

Selling Cheap Private Proxies (from 0.8$ on the bigger packs) and Super Cheap Shared Proxies  (from 0.25$ on the bigger packs)
Unlimited Bandwidth & Threads.
Anonymous Proxies. No logs are being stored.
All proxies are HTTP/HTTPS no SOCKS.
Non Sequential IPS.
You can request for the private proxies to be refreshed once per month.
Setup fee is not lost. You’ll use the proxies for another month after you’ll stop paying. The setup fee is there so we won’t have to take immediate action if you don’t plan on paying another month.
Do not use them for anything illegal or offensive.
An active subscription is required to maintain access to your proxies. I will remove your access within 1 month (setup month) and 48 hours of your subscription being cancelled.
Bulk discounts are available. If you start with 1 pack and later you’ll buy a few more , contact us and we’ll adjust your invoice with the new bulk pricing. ( Price list below).
Yearly discounts are available.
Depending on the pack of your private proxies you can choose a few locations.
The Shared-Proxies are from USA only
IP Authentification only.
Private Proxies : You get access to control panel where you can activate up to 10 IPs instantly.
Shared Proxies: You’ll get access on 1 IP only. You can change that IP via support ticket (no control panel access).
Our Guarantee:
If the proxies aren’t suitable for whatever you need request a full refund within 3 days of ordering! (For packs up to 101 proxies.)[/COLOR]
No vouche copies are available. We’ve been selling proxies among our private customers for a while now and just decided to open the service to the public.
Try it risk free with our 3 days money back guarantee![/COLOR]
Pricing! Monthly Payments!
Private Proxies:
10 Proxies – 10$ (1$ each)
60 Proxies – 60$ (1$ each)
100 Proxies – 95$ (9.5$ each)
500 Proxies – 450$ (0.9$ each)
1000 Proxies – 850$ (0.85$ each)
2000 Proxies – 1600$ (0.8$ each)
Shared Proxies:
100 Proxies – 35$ (0.35$ each)
200 Proxies – 60$ (0.3$ each)
500 Proxies – 125$ (0.25$ each)
1000 Proxies – 250$ (0.25$ each)
2000 Proxies – 500$ (0.25$ each)
[B]Wordwide Locations available atm:[/B]
[LIST]
[*]Sydney, Australia
[*]Ontario, Canada
[*]Quebec, Canada
[*]Beijing, China
[*]Estonia, Europe
[*]Sweden, Europe
[*]Ukraine, Europe
[*]Paris, France
[*]Berlin, Germany
[*]Frankfurt, Germany
[*]New Delhi, India
[*]Israel, Asia
[*]Tokyo, Japan
[*]Amsterdam, Netherlands
[*]Lisbon, Portugal
[*]Bucharest, Romania
[*]Zurich, Switzerland
[*]Essex, United Kingdom
[*]London, United Kingdom
[*]Rochdale, United Kingdom
[*]Staffordshire, United Kingdom
[*]Surrey, United Kingdom
[/LIST]
[B]USA Locations available atm:[/B]
[LIST]
[*]Birmingham, AL
[*]Mesa, AZ
[*]Phoenix, AZ
[*]Tucson, AZ
[*]Fresno, CA
[*]Hacienda Heights, CA
[*]Los Angeles, CA
[*]Sacramento, CA
[*]San Diego, CA
[*]San Francisco, CA
[*]San Jose, CA
[*]Miami, FL
[*]Atlanta, GA
[*]Honolulu, HI
[*]Chicago, IL
[*]Church Creek, MD
[*]Dearborn, MI
[*]Kansas City, MO
[*]Omaha, NE
[*]Las Vegas, NV
[*]Parsippany, NJ
[*]Buffalo, NY
[*]New York, NY
[*]Columbus, OH
[*]Edmond, OK
[*]Beaverton, OR
[*]Portland, OR
[*]Nashville, TN
[*]Austin, TX
[*]Dallas, TX
[*]Houston, TX
[*]Seattle, WA
[/LIST]
[CENTER]Contact me via PM, on site at https://www.bywex.com/contact/ or via skype at
[URL=’https://hatscripts.com/addskype?live:support_42971'][IMG]https://hatscripts.com/addskype/live:support_42971.png[/IMG][/URL][/CENTER]

Would My Custom Weapon Idea Work Well? [closed]

I had an idea to make a custom sword that increases its damage for every finishing hit it does. It would increase by 0.1% 0.5% or 1% each time. Earlier in the campaign it would be under powered and the player would have to grind it out but later in the campaign it would be over powered. Would a mechanic like this work or would it be a bad idea?

Thanks! Example

Bulk upload images with custom URL

I am running a library system on WordPress. Right now, my book cover images are saved like this:
/wp-content/uploads/2020/06/[book_barcode].jpg

I want to change this to /wp-content/uploads/library/[book_barcode].jpg, but this would also be fine:
/wp-content/uploads/[book_barcode].jpg

I have a bunch of other images, so I can’t change the entire organization of my media folder. I will eventually have thousands of book cover images, so doing each one individually would be tedious. Is there any quick way to bulk upload?