Articles of select

Making jQuery .change() event persistent after widget save

I’m creating a custom widget that uses a select element with a bunch of options and a simple jQuery function to trigger the visibility for some <div>s below it based on the selection, through a jQuery’s .change() event. As you see below, this fails when the widget is saved. If I select another option, it […]

Select query for a login

I’m trying to make a login form, but select query isn’t working. Is there another syntax in WordPress and in which way is password hashed? My code is: if ( isset( $_POST[‘submit’] ) ) { if ( !$_POST[‘username’] ) { echo “You did not complete all of the required fields”; } else { $username=$_POST[‘username’]; $password=$_POST[‘password’]; […]

Adding option values as an array using a multi selectable select box

I have a plugin I’m developing. As part of its functionality I need to set up an option group and specify an option var for that group: function swcs_settings() { register_setting( ‘swcs-settings-group’, ‘swcs_postpage_id’ ); } add_action( ‘admin_init’, ‘swcs_settings’ ); Where swcs_postpage_idis the name of my variable. I am using this variable in a <select> box […]

Custom select query two tables by a meta key

I’m using an event plugin which creates wp_ftcalendar_events table in database with start_datetime column. Here’s image of whole table: I want to query my posts by start_datetime. I know that I can’t do that with regular query. I also know that this query requires some conditions etc. but for a start I wanted to make […]

SELECT query with prepare and placeholder for string

I am trying to learn how to do a simple Select query using $wpdb-prepare. I am checking wether an email submitted by the user is already available in the database. There has to be something wrong with the syntax because the string placeholder is undefined, according to PHPstorm. $mail = $_POST[’email’]; $table = $wpdb->prefix . […]

Can I limit term selection to one plus parent?

So i have a custom post type (listings) and a custom taxonomy (listing_terms). The taxonomy has parent/child terms. Eg: Restaurant -> Cafe (where Cafe is the child of Restaurant). I want to only let my users to be able to select one child term and then have the parent term automatically selected when they’re creating […]

Display posts by combining multiple meta key

Basically a post is an event therefor will be displayed once or twice, depending on meta key. Every post has at least two meta keys $start_time_1 and $end_time_1. Let’s say i have two posts, title: “Radio Show” and “TV Show”. Radio Show – start @ 2016-07-01 12:00 TV Show – start @ 2016-07-01 15:00 My […]

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

I have a select tag (in filter.php) with different training prices ($80, $120, $500, etc). The values are stored in the array $options (thanks to Tom) : I’d like to display, when visitor clicks in $80, all pages with this value inside (prix_1) and so on… …then display results in current page (below the select […]

How to select one major category (or custom taxonomy) for a custom post type?

I’ve created a hierarchical custom taxonomy (genre) and want to use it for a custom post type (radio station). But I don’t only want to assign some genres to a radio station. I also want to be able to select one major/main genre as “most important genre” for each radio station. Is it possible to […]

Add “Select All” to custom taxonomy

Is it possible to add a “Select All” to a custom taxonomy for my custom post type? A project I’m working on requires the option to be able to select all of the taxonomy terms. While I could go through and manually click each term, it becomes quite cumbersome when I have several hundred terms. […]