WPIntell

Source evidence

How to use PHP Condition

Modal Dialog · support · 2016-07-12T08:33:00+00:00

complaintsentiment
mediumseverity
0.81relevance
1replies
Evidence linked to opportunitycommercial context

Proof Health

Open evidence

Commercial opportunities need traceable source links before they are treated as build-worthy.

4 / 23 rows with source links

17.4% of this page's analysis has direct source links.

0 build-decision rows missing links

0 rows here require auditable proof before promotion.

19 rows with no attached evidence

0 rows have source counts but still need direct links.

Conversation

support
Woohoo61 unresolved
Hi all, I’m pretty new to PHP. I want the Modal to show on page with ID 371 when a variable has a specific value. Say on page ID 371 I have set: $modal = 'A'; Then in the settings of the Modal I set at the PHP Condition line: if($modal == 'A'); Changing the variable on that page to, say, ‘B’, that doesn’t make any difference. The modal keeps showing up. I have checked the ‘Only show on specific pages and single posts’ and specified the page ID 371 on ‘Pages and posts to display Modal Dialog ‘. Any clues anyone? https://wordpress.org/plugins/modal-dialog/ You should not put if and semi-colon, only what is between parentheses. $modal == ‘A’ That being said, you are going to get in a scope issue. Where are you trying to set that PHp variable? It will not be available from an a shortcode callback function. If you want a shortcode to optionally display on a page, a better bet would be to put a GET variable in the URL. For example: http://mysite.com?p=371&showdialog=1 Then your condition could be: is_page(371) && isset( $_GET[‘showdialog’] ) && $_GET[‘showdialog’])

Comments

1 shown
Yannick Lefebvre 2016-07-12T23:49:00+00:00

You should not put if and semi-colon, only what is between parentheses. $modal == ‘A’ That being said, you are going to get in a scope issue. Where are you trying to set that PHp variable? It will not be available from an a shortcode callback function. If you want a shortcode to optionally display on a page, a better bet would be to put a GET variable in the URL. For example: http://mysite.com?p=371&showdialog=1 Then your condition could be: is_page(371) && isset( $_GET[‘showdialog’] ) && $_GET[‘showdialog’])