Skip to main content
Share Your Experience: Take the 2024 Developer Survey
4 votes

How to get last user with wpdb?

If you're trying to get the last user created with the username format usuario*, I'd recommend using get_users() instead of writing a SQL query. $args = array( "search" => &...
Pat J's user avatar
  • 11.9k
3 votes
Accepted

Changing select options based on previous select with PHP & AJAX

The first step you'll need to take is to reorganize your code a little. WordPress allows you to register Ajax calls via an action, wp_ajax. This is a safer and easier way to create an ajax call that ...
Tom's user avatar
  • 1,286
3 votes

Custom contact form 7 select with custom values

You can set the values with the filter wpcf7_form_tag and add the shortcode attributes with the filter shortcode_atts_wpcf7 add_filter("wpcf7_form_tag", function($scanned_tag, $replace){ if ("...
mmm's user avatar
  • 3,704
3 votes

Triple meta_key on custom SELECT query

There's nothing wrong with the other answer but I thought I'd add this as a different method as it's simple and uses WP to work out the SQL Query. It would be slightly heavier on resources as there ...
Bysander's user avatar
  • 1,225
3 votes
Accepted

Triple meta_key on custom SELECT query

Your Query is incorrect. To retrive meta values for triple meta_key you will need 3 different joins using posts meta on posts table. Check code below: // Example value $user_id = 1; // Calculate ...
C Sabhar's user avatar
  • 399
2 votes
Accepted

How to replace a javascript select box onchange event to a form submit action?

It's not working because: You are redirecting home You don't listen for the $_GET variable so the archive link is just appended to your home url You need to add a function that listens for that $...
bynicolas's user avatar
  • 2,279
2 votes
Accepted

Can I limit term selection to one plus parent?

I found an answer that works well. Using two dropdowns in a 'cascading' style, with the code in the gist below, users would pick from a list of parent terms first, then a second dropdown appears with ...
Aaron's user avatar
  • 325
2 votes

How to correctly submit a search form and display the result in an independent page

To create your own independent search functionality, follow these steps. 1- You need a form to send the data for you. This is a simple form that can do this for you: <form method="post" name="car-...
Johansson's user avatar
  • 15.3k
2 votes
Accepted

ACF Pro select field problem

You can loop through your ACF options by using the code below. <?php if( have_rows('social_medias', 'option') ): while ( have_rows('social_medias', 'option') ) : the_row(); $type = ...
Nuno Sarmento's user avatar
2 votes
Accepted

Select dropdown not showing selected value php

The reason your $item == $option condition is always failing is because of the way PHP compares floats! Try the following instead: echo "<option value='$item'" . selected (abs ($item - $options) &...
Paul 'Sparrow Hawk' Biron's user avatar
2 votes
Accepted

Wordpress shortcode attributes for database SELECT?

Here's the SQL query: $simplelist = $wpdb->get_results("SELECT `Row1`, `Row2` FROM `table` WHERE `Row1` = " . $atts[...
Tom J Nowell's user avatar
  • 59.4k
2 votes

Make Selected Mutiselect Items "selected"

I know this is an old question but still the answer was not answered using the core function... Here it is: $cats = get_categories('hide_empty=0&orderby=name'); ?> <select name="<?php ...
Paolo's user avatar
  • 103
2 votes
Accepted

How to populate a select field with post titles/ids in a block

I managed to come up with a solution myself. To get a list of posts of a specific post type one must wrap the wp.data.select( 'core' ).getEntityRecords() selector inside the withSelect higher order ...
leemon's user avatar
  • 1,908
2 votes

WordPress setting with select - where is my mistake?

The problem is that in your calls to selected() you haven't set the 3rd parameter to false. For both selected() and checked() if you don't do this it will echo the attribute immediately, which won't ...
Jacob Peattie's user avatar
2 votes
Accepted

Modify output of wp_dropdown_categories to add term IDs to each option

get_terms ended up bring a more customizable solution which is working for my needs. I was able to easily add the term IDs to each option as needed. Hope this helps someone else. <div class="...
Greg's user avatar
  • 31
1 vote
Accepted

Sorting dynamic select/dropdown for Contact Form 7 of Modern Tribe Events posts

For any poor soul out there that stumbles on the same, niche problem, the answer was frustratingly simple. Instead of trying to reinvent the wheel and build my own query, I should've been using the ...
iprobablyhavenoanswers's user avatar
1 vote
Accepted

Wordpress select field - show current value?

By referencing to the source code, this function supports an argument called value which you can pass one of the keys inside the options array like this: function woo_add_spin() { ...
Farsad's user avatar
  • 257
1 vote
Accepted

Multiple selection for wordpress widget

Hi why don't you used multiple check-box instead of select option field. As well as you have used deprecated functions like "create_function". I have modified your code which replaced select option ...
Nilesh Sanura's user avatar
1 vote
Accepted

Check if a value exists in database table

Replace this: $result = $wpdb->get_row("SELECT * FROM wp44_predefined_address WHERE 'UPPER(Address1)' LIKE 'UPPER(%s)'", $myinput); with this: (just choose the appropriate $like based on your ...
Sally CJ's user avatar
  • 39.2k
1 vote

I have 2 post types i need to show the post type contents in 2 select boxes

Below Code will generate Select box of post type "resources" change this value as per your post type. <select name="page_id" id="page_id" class="archive-dropdown" onchange="document.location.href=...
megi's user avatar
  • 81
1 vote
Accepted

Retrieve select tag custom values from array and display them in current page with wp_query?

@Nick83, While I'm not trying to make the answer overly complicated, in order to do what you are attempting to do correctly I believe you'll need to call WordPress via Ajax. My recommendation is ...
Tom's user avatar
  • 1,286
1 vote
Accepted

Style the last element having a specific class

There is no (good) way to solve this problem in its current state with CSS. The best solution is to add an extra class to the last active div, or to use javascript See this question for more details
Sjors Ottjes's user avatar
1 vote
Accepted

add onchange to select in a wp form

you can add any attribute to <select> using wordpress filter wp_dropdown_cats . wp_dropdown_cats filter allows you to modify the content of the taxonomy drop-down output. Try below code. ...
GKS's user avatar
  • 1,306
1 vote

add onchange to select in a wp form

Use JQuery change method $('#my_cats').on('change', function() { myFunc(); }); function myFunc() { // your function code }
fmeaddons's user avatar
  • 396
1 vote

ACF Pro select field problem

I would do this instead: <?php if( have_rows('social_medias', 'option') ): while ( have_rows('social_medias', 'option') ) : the_row(); $type = get_sub_field('type'); ...
Nuuu's user avatar
  • 123
1 vote

How to convert select to HTML with PHP tags inside of it

I found a way that was consistant with the rest of my HTML formating within my child theme. The following works just fine. <p> <label> <select name="...
klewis's user avatar
  • 857
1 vote

How to convert select to HTML with PHP tags inside of it

There are the couple of ways to do this. printf sprintf A better and more efficient way is to use printf in your code like this: printf( '<p> <label> <...
Syed Fakhar Abbas's user avatar
1 vote

How to convert select to HTML with PHP tags inside of it

An example: your code <option value="0" ' .selected($horizon_featured,'normal',false) .'>Descending</option> HTML code with some PHP mixed in: <option value="0" <?php echo ...
Rick Hellewell's user avatar
1 vote

How to make drop down post title

It's better to use the wp_ajax_ action in an init action. In fact, wp_ajax_ action need to be accessable from anywhere. Use of the init action hook could make it work like it does. Hope it works
Benoti's user avatar
  • 2,436
1 vote

How to call custom jQuery plugins into the customizer controls

First, in order to enqueue JS in the customizer controls, you need to use the customize_controls_enqueue_scripts action. This is different than the action used to enqueue scripts into the customizer ...
Weston Ruter's user avatar
  • 4,020

Only top scored, non community-wiki answers of a minimum length are eligible