Questions tagged [php]

For questions about the server-side programming language that the WordPress core, plugins and themes are written in. Questions about using PHP outside a WordPress context are off-topic but might be asked on Stack Overflow.

Filter by
Sorted by
Tagged with
1
vote
1answer
1k views

How do I test PHP files in WordPress?

I've downloaded a Wordpress theme, but I want to edit it before uploading it to my live server. I read I need to run a server in order to test the PHP files, but I don't know what to use in order to ...
5
votes
2answers
11k views

WordPress PHP version requirements

PHP 5.5 has been released recently. In the same time has been announced that PHP 5.3.x branch won't be supported anymore after 5.3.27 will be released. However WordPress requires PHP version 5.2.4 ...
0
votes
1answer
725 views

Custom field within shortcode

I'm currently using the 'WP Simple Paypal Shopping Cart' plugin to get up a simple paypal e-commerce site, it's super easy to use, but to save the client having to write shortcode, I've set up custom ...
0
votes
1answer
764 views

get comment data using comment id

I am using the get_comments() function which works well if I give it any array of parameters except if I give the following array: $defaults = array('ID' => $comment_id); $com=get_comments($...
1
vote
2answers
979 views

count number of user comments with a specific comment meta value

I am using the code below to count the number of comments by a certain user: global $wpdb; $count = $wpdb->get_var( 'SELECT COUNT( comment_id ) FROM '. $wpdb->comments .' ...
3
votes
2answers
22k views

Woocommerce -How to set product regular price default

I am using woocommerce at work for equipment requests, therefore all products I will create will need to be £0. Is it possible to set a default value of 0 for the regular price field on the add ...
0
votes
1answer
1k views

meta box not display data input in the textarea

I've had multiple errors with this metabox, first I thought Id fixed a undefined index error with the code below but now that doesn't appear my metabox doesn't save any data. code before the error: ...
0
votes
1answer
108 views

creating a second image attachment template?

Hi i am trying to create a second image attachment template. I have one, but I have created another. In the second one I want the attachments that are under a certain category of a post to have a ...
0
votes
1answer
204 views

Post Title Not showing up

Hi i'm using this code to call post from a certain category <?php $queryObject = new Wp_Query( array( 'posts_per_page' => 3, 'post_type' => array('post'), '...
-2
votes
1answer
98 views

metabox displaying on incorrect page

I've got two different functions that output different metabox's one is for the pages and the other is for just the post. For some reason the one I created for posts overwrites the one on pages and ...
-1
votes
1answer
410 views

Options.php loop won't show!

I'm creating an options panel for a theme on my localhost that's stored within the options.php file. My options panel will have two main loops. The first is to list the different sections and the ...
0
votes
2answers
2k views

Pagenavi pagination via wp-query in functions.php showing same content for each page

I've recently had a lot of help creating an upcoming events list (see here Showing upcoming events including todays event - StackOverflow), as a result my pagination using wp_pagenavi() is broken. At ...
0
votes
1answer
118 views

Trying to change image funtion from enlarge image to redirect to amazon website

So im making an amazon affiliate website. the theme im using (ebuy) enlarges the image when you click on it. I'd rather just have the image take you strait to amazon. i went poking around in the ...
0
votes
0answers
210 views

syntax error unexpected '}' at 364 line

I am getting this error on my website and am not able to access admin dashboard. The error occurs when I am a new theme on my website. Can you please help me to find this error. Parse error: syntax ...
0
votes
1answer
2k views

Post meta select input, if statement

I have created a meta box with a select input (drop down menu). It has a few values and I want to display different content depends on which value the user selects. I am just unsure how to display ...
0
votes
1answer
1k views

How To Pass Array To get_the_category_by_ID() and Get An Array Back?

I am trying to pass an array of category IDs to get_category_by_ID() in order to get an array of category names back. Since I'm still trying to get this to work I'm just using var_dump() on the output....
1
vote
0answers
195 views

Checkbox doesn't stay checked, conten

I'm using the morefields plugin to create textfields and checkboxes in the dashboard. For a test I have first created a checkbox on 'pages' if it was checked, the frontend showed the text 'TESTCONTENT'...
10
votes
1answer
2k views

How can I save a multiple select array with the settings API for a plug-in options page?

I'm thinking this may be more of a problem with my PHP rather than my use of the settings API, but I can't seem to get Wordpress to save an array of data for a multi-select box. The multi-select box ...
0
votes
1answer
259 views

Clickable image link sends people to wrong URL

On my website www.wilsonstransportation.com, on the header of our custome theme page, we have a "Get a Quote" image on the right hand side. When you click it, it is taking people to http://...
1
vote
1answer
2k views

Conditional statement for parent, child and grandchild pages

I'm trying to figure out how to set up a conditional statement to check if the parent, child or grandchild is being displayed. This is what I've got so far: <?php if ( is_page( 'about' ) || '29' ...
0
votes
1answer
783 views

advanced custom fields: repeater field within conditional statement [closed]

I'm trying to figure out if it's possible to have a custom field within a conditional statement. e.g— if ( is_page( 'about' ) || '29' == $post->post_parent ) { //custom field goes ...
0
votes
1answer
851 views

Prevent multiple counts by same user - WP PostViews plugin

I am using WP Post Views plugin to display the post number of views. To do so, I use: <?php if(function_exists('the_views')) { the_views(); } ?> The problem is: The plugin increments the ...
0
votes
2answers
53 views

conditional statement expressing that current user didn't logout (is still in the same login session)?

Thank you in advance for your time. I want to perform the following conditonal if: if (current user didnt log out and is in the same login session ) { Do_something; } How to express it using Codex ...
2
votes
1answer
4k views

How to get Poster (thumbnail) Image of Video

I'm getting all videos using the function below and it's working fine. Now I want to get the videos Poster Image (Thumbnail Image) from that video. How can I get the video Image as thumbnail? I've ...
1
vote
0answers
106 views

Help with .htaccess and Login with Subfolders

I know this question has been asked many times, but I still not sure whether I have this correct. I am trying to make it so that my login page is here: www.url.com/login My WordPress installation ...
0
votes
1answer
62 views

Wordpress Options Page Theory Question

I created an options page and it is functioning perfectly, but I am not sure I understand how it functions. It's cool I got it to work but I was hoping someone could help explain why it works. Here ...
2
votes
1answer
2k views

Using a nonce in a Custom Login Form

I am trying to create my own login form for WordPress using wp-login.php as a template. In the form that is used to collect login information from the user (lines 680 through 703 of wp-login.php), ...
0
votes
0answers
128 views

get_post_meta no longer working

I am trying to use get_post_meta to return a value from the post meta, it was working completely fine then suddenly stopped working. I've tried and checked everything and i cannot seem to get it ...
0
votes
1answer
759 views

How to add videos on my home page slider?

How would you recommend adding videos to my website's home page slideshow, here is the php code that creates the slideshow: <?php global $gpp; ?> <div class="app"> <div id="slideshow"&...
1
vote
2answers
4k views

Insert After Second Paragraph Without <P> Tag?

I use a code like the one shown below to insert ads after the first paragraph. The problem is that this code requires the content to be displayed within paragraph tags and I would like to use this ...
0
votes
1answer
54 views

Advanced Taxonomy query, with 3 post types

I'm been trying to figure out how to do this for a few hours now and Have final given in to asking for help. I've got 3 custom post types that I need to query for a term called home which is inside a ...
0
votes
1answer
48 views

Difference in Get Variable Location

I have noticed that in some instances in WordPress (such as in my custom post types), GET variables appear as following in the URL: www.url.com/events/cool-event?action=edit&message=1 However, ...
0
votes
3answers
3k views

Custom Widget outputs the input but doesn't save anything inside the textarea

I've been working on my first widget, Everything works perfectly except it doesn't save anything I add to the textarea box. It will output the input on the website however. From research I think its ...
2
votes
1answer
13k views

How to Explode a Textarea Field and Echo each line separately, wrapped with HTML

Need to take an advanced custom field textarea and display it in my template by breaking out each line separately. I want to wrap each line of the textarea with HTML, like an <li>. I've tried ...
-1
votes
2answers
856 views

Wrapping the_content() in Schema articleBody tag? [closed]

I am trying to put the_content() inside <meta itemprop="articleBody" content="(content here)">. But if I just put <?php the_content() ?> in there, it doesn't work, image goes, structure ...
1
vote
1answer
125 views

How do I limit the number of forms a user can create in gravity forms?

I've been looking at Gravity Forms, and whilst it's a great plugin, it's missing some features. I really want the ability to limit how many forms can be created by a role: Administrator - Unlimited ...
1
vote
2answers
7k views

If Meta Checkbox is checked, do something?

I created a custom checkbox that when I check, I wish it to display slightly different content (specially special css styling). For some reason it is not functioning properly. In my functions: ...
0
votes
1answer
4k views

wpdb prepare insert table doesn't work

I followed the introduction to use prepare to insert some data to the table. The code is like this: $wpdb->query( $wpdb->prepare( "INSERT INTO {$wpdb->prefix}...
0
votes
0answers
65 views

Highlight posts currently being edited on multiple editor site?

I have a custom page that uses the Cleverness To-Do List plugin to display multiple posts on a page. My site has multiple editors, and if a post is currently being edited on the custom page (not the ...
0
votes
1answer
89 views

Keeps asking Connection Information upon update to 3.5.1 (but not for plugins?)

for starters, I am using WordPress on a live server in which I can only login using sftp with an ssh key. I want to install and upgrade to the latest version of WordPress (currently at 3.4.2, but ...
0
votes
1answer
81 views

select a single val though a table in wordpress

The table is like this: category_id category_name category_parent_name I would like to get category_id by using category_name. I searched online, and the code is like below: $ad_cat is the ...
1
vote
1answer
111 views

How to add equivalent of php include to one page (as plugin?)

I'm new to Wordpress. I have a website that I coded myself. One of the pages has PHP functions that take a google calendar feed (with hard-coded login info) and displays it as needed. I am now ...
0
votes
1answer
473 views

How to add 3 weeks to the_time() function

I have a WordPress blog where I need to display an image on each post only for 3 weeks. This means that after 3 weeks have passed, since each post was published, the image will disappear. First, I ...
0
votes
1answer
2k views

How to display custom post type only on a certain page?

I have created a custom post type called 'project'. But how do I get the custom post types to display only on my main template? It's a one page website and I don't want it to direct the visitor to a ...
0
votes
1answer
210 views

MySQL database migration to WordPress

I have a MySQL database established for a web application I have been working on in a non WordPress database. This database has many tables with pre-populated rows for foreign keys etc. which took a ...
0
votes
2answers
41 views

Dark Bar at the top of wordpress page can't be seen?

I am new to wordpress and created a website as shown in the picture bellow. My webpage used to have a black bar at the top, which allowed me to insert "New Posts". (area shown in red circle). But this ...
0
votes
1answer
241 views

conditional: if is page, and all subpages

What I'm currently trying to achieve is displaying certain menus on certain pages using one template and conditional statements, like so: if (is_page('donate')){ wp_nav_menu(array( 'menu' ...
0
votes
1answer
13k views

Trouble Installing Wordpress Get PHP Not Running Answer

I have seen this topic discussed several places on the internet, both in the Wordpress official forums and on individuals' blogs. Despite having worked through some of the suggestions, I am still ...
0
votes
1answer
1k views

wp nav menu: show submenu below li item

I'm trying to figure out if it's possible to show the submenu's outside of the relevant li tag. For example, this php: wp_nav_menu(array( 'menu' => 'side', 'container' => false, '...
15
votes
2answers
33k views

Query multiple custom post types in single loop

I'm aware there are several other posts that cover similar ground to what I'm about to ask. I have three custom post types running, in addition to 'posts'. I want to run a loop that pulls all posts ...

1
142 143
144
145 146
176