Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

1
vote
1answer
3k views

Problem with Woocommerce REST API Authentication

I am using the postman for the check the REST API Call in WooCommerce. When I call the Woocommerce Defaults API. It displays the error like. { "code": "woocommerce_rest_cannot_create", "message": "...
0
votes
1answer
10 views

Use of undefined constant THEME_PATH

How can I fix this error? Got error 'PHP message: PHP Warning: Use of undefined constant THEME_PATH - assumed 'THEME_PATH' (this will throw an Error in a future version of PHP)
-1
votes
1answer
11 views

Is it possible to print only array keys using loop in php? [on hold]

Is it possible to print array keys using a loop? Then I want to put then inside the input type. $cr_table_array_new = array( 'Name' => array('text'=> array('Enter Name')), 'Email'=> array('...
0
votes
1answer
1k views

Define category ID using get_post_meta

I need to define the Category ID in my singles page through custom fields so that i can load a different category depending on the page. This is what i have so far and its not working. Any help would ...
0
votes
1answer
21 views

Issues when changing == to ===

What am I missing... when using === in the code, the front end doesn't show an element at all until I disable and then re-enable an option in the WP Customizer. For example, I have a logo that can be ...
0
votes
1answer
19 views

Using featured image of blog archive page

On my custom wordpress theme, I am using the featured image thumbnail for all of my pages to be the header of the page. I've created a page called "blog" and using it as the archive ( via settings ->...
0
votes
1answer
10 views

Primary navigation menu with timed items from custom post type

I have created a site (livermorevalleyopera.com) for a client. I made a custom post type for events. In the primary navigation I have a top level menu item "Season Events & Tickets" and the ...
0
votes
0answers
15 views

How to show galleries from a specific NextGEN album ID inside a custom WordPress page template?

I have a WordPress page template where all NextGEN galleries are displayed on a page: <?php global $nggdb; ?> <?php global $wpdb; ?> <?php $galleries = $nggdb->find_all_galleries('...
0
votes
2answers
24 views

Tell wordpress to show a single page instead of an archive page

my wordpress site urls like this: https://example.com/?pid=a125a5&lang=en and query of my archive page like this: <?php $the_slug = get_query_var('pid'); if ($the_slug){ if ( $post = ...
3
votes
1answer
816 views

the_author_posts_link css class

Currently I'm styling as project where I need to add a custom CSS to the_author_posts_link(). I want to add the class "blog-link" with the the_author_posts_link() . How do I add a css class to it?
5
votes
1answer
1k views

Creating a post with the REST API, curl and oauth returning 401 error

I'm trying to create a WordPress post using the REST API, OAuth, and cURL. However, I'm running into some trouble. I'm able to create a blank post (no title, slug, etc) using the following code: $...
0
votes
0answers
12 views

WordPress Media Grid - not loading pictures

The following page contains 2 media grid sections. The media grid under title: Finishes is not loading. I only see animated loading dots but the pictures won't load: http://acdwheels.com/brixton-...
0
votes
2answers
14 views

WordPress filter from custom table is not working properly

I want to filter the exact information from a custom WordPress table no matter the user has filled all the text boxes or not. I have used a LIKE query but it`s not working properly if the user left ...
1
vote
1answer
14 views

Add to checkout total lines an additional line below shipping in WooCommerce

I need add "Include pack" line with conditional logic to WooCommerce checkout review order section. How it possible?
0
votes
1answer
999 views

Add prefix to link url

I want to add image link on wordpress site which redirect the user to the another page of same url but with different prefix. for example page url is mydomain.com/post1234 when user click the image on ...
0
votes
1answer
1k views

Search not showing all results

EDIT: So I've done some troubleshooting and it seems my theme isn't showing woocommerce search results. The 2017 theme does so I am trying to figure out what my theme is missing. I suspect something ...
0
votes
0answers
13 views

how to make Wordpress DB lookup code to do “if” funcation

I have a wordpress website that using WPUM to creat accounts and mange them and a coustem plugin for memberships. When users creat an account they chose from membership plugin membership kind ( Sun - ...
0
votes
1answer
41 views

Reason to add a name of the theme like ('menu-1' => __( 'Primary', 'twentynineteen' ),) in PHP?

Sorry for this novice question. I'd like to know why WordPress themes add their theme names many occasions in PHP files (e.g. where 'twentynineteen' is repeated below, this is from functions.php in ...
0
votes
1answer
13 views

HTML tags in bloginfo description

I'm trying to set some <span> tags in the bloginfo description. So I put this in the blog description field: <span class="name">Archive | Navarro Vives</span> <span>is a point ...
0
votes
0answers
21 views

How to override WooCommerce Order Item Meta with data from Cart?

I have the following function that is overriding some of the values that are saved to the Cart and Checkout, via the YITH Bookings plugin. Essentially, I have overridden the Duration field with my own ...
1
vote
1answer
14 views

Change the displayed shipping total in WooCommerce

I need to change shipping price programmatically: <?php $percentage = 50; $current_shipping_cost = WC()->cart->get_cart_shipping_total(); echo $current_shipping_cost * $percentage / ...
5
votes
2answers
1k views

Need help setting default setting value for radio button in theme customizer

I need help figuring out how the radio button saves it's value in the theme settings. In my theme I added Radio buttons in the theme customizer. So far they are working great. Although I have one ...
0
votes
1answer
19 views

How to echo a PHP Code After the Content

i wanted to execute a code after the Content of each blog post. I just want it to be on posts and not on pages. I could execute simple html by the method but could not put the following content. ...
0
votes
0answers
10 views

Convert any video formats to MP4 - PHP/WordPress [on hold]

As except MP4 format, browser is not supporting other formats. I have heard about FFmpeg but how it works in my localhost that doesn't know! So is there any plugins or any library available that ...
0
votes
0answers
11 views

gallery with post category and custom fields

I'm trying to create a YouTube gallery where i use Posts to get info of the iframe and Feature image. I've built the following gallery: <?php global $post; $args = array( 'posts_per_page' => -...
0
votes
1answer
1k views

PHP calling function within a class

I'm writing my own php class and I have multiple functions within the class. Something like this: class JSON_API_Hello_Controller { public function test_cat(){ global $json_api; ...
1
vote
0answers
9 views

How to bypass maintenance mode with external cron?

I'm using crontab to run a php script loaded with wp-load.php with absolute path. However, when I go to maintenance mode, the file can't run. I'm using Coming soon plugin. Is there a way to exclude ...
9
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 ...
1
vote
1answer
1k views

how to update and display an option without reloading the page

Hello I have a select box in which when one item is selected a update_option event fires and get's the selected item's value and echo's it on the page without having to reloading the page. I've put a ...
0
votes
1answer
7 views

Woocommerce: Display an image on Products from a Specific Category?

Does anyone have code that can be added to functions.php that will allow me to display an image only on products that belong to a specific category? Preferably I'd like it to display over top of the ...
0
votes
2answers
17 views

Custom post type category not displaying category ID

I'm trying to get the category ID so I can call a loop query on only that category ID. However the following code returns null. Any ideas why? In the admin bar it shows edit category with an ID of 3, ...
0
votes
0answers
7 views

Redirect user after form submit alert message

I need to display a javascript alert after a form submission and then redirect the user to the home. I have this code, but it will always redirect the user to the wp-admin/admin-post.php page. How I ...
0
votes
1answer
34 views

How do I wrap this?

I have snipped of PHP code I'd like to have wrapped within its php-file with the do_shortcode function. Unfortunatly, I don't have clue how to do this. Several ways I tried end in an error on the page....
1
vote
2answers
2k views

Setting value of session with Ajax not working

I´m kind of new to using Ajax but I am trying to update the value of a session using Ajax. The Ajax call shoud fires when clicked on a button. When I click on this button it also returns the succes ...
1
vote
1answer
23 views

Display a selected custom product option in WooCommerce cart

I am using the code below to display a custom select field on WooCommerce single product pages: <?php $sizes = $product->get_attribute( 'size' ); $sizes = explode(", ",$sizes); ?> <?php ...
1
vote
2answers
959 views

How Can I use WP_Query to Only Display 1 Post from Custom Post Type if Query Returns Posts with Matching ID in Custom Field

I have searched high and low for a solution and couldn't find anything; hopefully someone here more skilled than myself can lend a hand. I have two testimonial videos (from a video custom post type) ...
1
vote
1answer
20 views

Which field should I edit to make the checkbox marked by default?

I have a php form that I want to change the state of a checkbox so it's filled by default, but there are two fields that may be the right way: 'request_vendor_access' => array( '...
0
votes
3answers
838 views

Add URL parameter to all internal links using a specific theme

I got stuck with some modifications and maybe someone could give me some help. What am I doing I use the multiple theme plugin to switch themes for my WordPress project. To switch between the ...
0
votes
1answer
17 views

Get first URL from post content

Basically all I want to do is if the post format is "link" rather than link to the post from the blog index, link to the link pasted within the post content. In my index.php I have: <h3> <...
0
votes
0answers
15 views

I want my category (archive) pages to mimic the structure/style of my Posts (home) page

Theme I'm using is easymag-pro. I will paste both pages below. I know I have to replace the archive.php with my home.php, but I need to add something to the new archive page so it will pull the posts ...
0
votes
1answer
22k views

Post + form + action + results on the same page

I'm trying to put on a post a custom form and, on the same page I'd like to visualize the results of an action on the form. But I'm missing the basics. Essentially I'd like to do something like this....
-1
votes
1answer
17 views

how do integration Carousel on Wordpress?

Get help from you how to place Carousel in this code that I have now: <div class="black"> <section class="t-grid-11"> <div class="t-grid-i"> <div class="t-grid-i-i"> <...
0
votes
0answers
7 views

503 Server Error Code [closed]

Hi I would like to ask regarding my error I get. The problem solve after I increse the MAX_EXECUTION_TIME & MEMORY LIMIT . But after a few days the problum occur again which I need to increase and ...
1
vote
3answers
9k views

if plugin is active? check if plugin is enabled or not?

I'm using the mingle plugin and the mingle-forum plugin. I want to show a certain part on my site only if those two plugins are active. How can I solve this? <?php if ( is_plugin_active('mingle-...
0
votes
1answer
1k views

How to solve 404 permalink errors on nginx server

I can't solve this issue. I tried everything I found over the web. I first tried configuring my nginx.conf following the example on codex with no success. https://codex.wordpress.org/Nginx I found ...
0
votes
1answer
28 views

Return author name as a tag using get_author

I'm trying to display the author name as a tag. I looked at many forums and it's referring to the get_author methods and the PHP files from the template PHP. However, I do not know what changes to ...
2
votes
1answer
30 views

Get WooCommerce product details and transfer them to a custom DB table

I'm currently doing a registering service for products with WordPress and WooCommerce. All products that customers can register will be in the WooCommerce database, but not visible on frontend. Here ...
0
votes
0answers
11 views

How to save and retreive an array from checkbox list in Theme Options [closed]

I am developing a very simple WP theme and I wonder how could I get this functioning. The main goal is to save the value of the selected checkboxes and retreive it in the front-end footer to load the ...
0
votes
1answer
19 views

How to add a new column with text fields to WooCommerce Cart List?

As attached images. How to add a new column with text fields to WooCommerce Cart List? Thanks.
1
vote
1answer
482 views

Executing my function once on a specific time

On our WordPress website we are using the Events Manager Pro plugin. This allows us to create events. However we need to somehow send a thank you E-mail to the attending people 1 day after the event ...