Stack Exchange Network

Stack Exchange network consists of 174 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.

0
votes
3answers
31 views

get_the_content if it contains multiple lines it results in SyntaxError

I use get_the_content to pass to a javascript variable, and then back to another PHP function. This works great, but there is an issue when using get_the_content. If the post contains only one line (...
0
votes
3answers
25 views

Is there a way to get wp_editor (tinymce) content?

I want to get the wp_editor (tinymce) content then find a sentence by specific word with regex. However, have no idea how to get the content When a post is published or updated, the function will get ...
37
votes
5answers
112k views

How to get URL of current page displayed?

I want to add custom PHP code to ensure that whenever a page on my site loads in my browser, the URL of that page is echoed to the screen. I can use echo get_permalink(), but that does not work on ...
0
votes
1answer
15 views

How to align buttons properly

I am using below code on my function.php file to display two buttons. function action_after_question_content() { if (!is_single()) { echo "<a class='button-default' href='"....
3
votes
1answer
701 views

How to Join two tables from separate databases within Wordpress

Using wpdb to connect to a separate database I have connected to my other database with this code $mydb = new wpdb('username','password','database','localhost'); Now I need to do a Join of a table ...
0
votes
0answers
18 views

wordpress sql query pagination

for example, I want to Page the remaining comments after calling 50 comments. the page where I call the function <ul class="list-group"> <h2 class="h3">gündem <div class="...
0
votes
1answer
510 views

Get all posts including sticky ones with get_posts(),setup_postdata(), and foreach loop?

I am using this code to fetch my posts: <?php if ( get_query_var( 'paged' ) ) { $paged = absint( get_query_var( 'paged' ) ); } elseif ( get_query_var( 'page' ) )...
0
votes
1answer
30 views

i want add conditional for add category in wordpress

i have marketplace plugin when the seller want add product first he will choose category i want change this code to for example i have 2 main category ( A - B ) and i have ( C - D - E ) under A ...
0
votes
0answers
11 views

I want to create custome voting system in wordpress website [on hold]

I created one simple website in wordpress https://goo.gl/QkxokT I want to create custome voting system in php for this website. Can anyone help me in this regard. I really appreciate it.
0
votes
2answers
524 views

Permalinks not working after updating WordPress

Recently I have installed a new version of WordPress and immediately I tried to change permalinks to /%postname%/ and now it's not showing the result. Everything is default according to WordPress....
0
votes
2answers
22 views

Wordpress member notification

I try to implement a function to notify users about changes on the webpage. I tried to use sessions for that but it did not work very well. For example: A User can attend an event. To do that he has ...
7
votes
1answer
502 views

Pass media upload value to input field

I have created a meta-box that provides a upload function via the default media uploader from WordPress. This works fine as long as I have one upload option. But guess what? I want another one. If I ...
-1
votes
0answers
23 views

WordPress | ACF | Using a variable to get_field()

I am trying to pass a variable to the function get_field($variable) from Advanced Custom Fields. This is my code: <?php // create base begining with a ' $tweet_box_size = '\'grid_box_size_'; ...
0
votes
1answer
16 views

Remove generated category and tag class names from woocommerce product & blog listings markup

I noticed in my wordpress/woocommerce setup that every time i add a tag to a product or a blog post. It adds that tag as a class into the listed item (Product/blog) I also noticed it adds a class in ...
0
votes
0answers
23 views

index.php file keeps redirecting to a non-existent index.html file?

Every time I try and visit the index.php file on my website, it automatically redirects me to an index.html page. I have no redirects in .htaccess. My wordpress site is in a subdomain, but it ...
1
vote
2answers
13 views

Print last modified date only on posts

I'm printing the last modified date via functions.php with the following code function wpb_last_updated_date( $content ) { $u_time = get_the_time('U'); $u_modified_time = ...
-1
votes
0answers
12 views

Fetch Custom post type data with custom toxonomy

I'm trying to create custom post with custom fields in wordpress. I want to all data like title, description and custom taxonomies using custom php.
0
votes
1answer
492 views

how can I disallow special characters, space, capital letter, dot in user name on registration?

i am running membership site. any one can registered on my site. i want to disallow special characters(ie:!@#$%^&*), space, capital letter, dot(.) in user name on registration. i don't have any ...
0
votes
1answer
488 views

Add specific content after specific text in every post

Suppose I want to add some imagess in my all posts Eg. I want add this : <img src="ad.png" > after this text That's all every post & that image should be different in different category....
0
votes
1answer
35 views

Need help with format of nested array in MySQL

I build a plugin, that is able to run through a CSV file and parse the variables into custom fields of a custom post. In my custom post type, I build a meta box with repeatable custom fields. The ...
0
votes
1answer
491 views

Remove category from pagination

I'm trying to modify a old theme but im getting stuck on this code $post_type = 'portfolio' == get_post_type() ? 'portfolio' : 'post'; if ( ! themify_check( "setting-{$post_type}_nav_disable" ) ) : ...
0
votes
2answers
28 views

Inline style to PHP

I have a piece of PHP code to grab my post title which I am putting inside of a PHP element on my page builder. $h4 = get_the_title();`echo '<h4>' . $h4 . '</h4>';` I want it to be a H1 ...
0
votes
0answers
22 views

Custom cart link - Woo [on hold]

I'm creating a custom Woocommrce theme for a first time. I need help with displaying cart link in header. It looks like this https://imgur.com/AjARqhX and need to be like this https://imgur.com/...
0
votes
1answer
11 views

Return to the beginning of the results of a for loop

I am currently doing a little script (and I am rather beginner), I would like to know how to return to the result number one of a for loop after the table containing the results have been traveled? ...
0
votes
1answer
501 views

How do I create a single Wordpress page that will use PHP to include different HTML files based on a vaule in the URL?

I have used PHP on a page to include HTML files on a page such as: <?php require("http://www.mysite.edu/_sports/static/season_box.html"); ?> This works well for including a single file that ...
0
votes
1answer
24 views

PHP question: how to combine syntax?

could someone please tell me where the mistake is in my PHP code? My PHP knowledge is extremely rudimentary although I have tried it with http://php.net/manual/de/language.operators.logical.php :-D "...
0
votes
1answer
11 views

Issues Installing WP CLI

I'm trying to install wp-cli on my vps. Running the command php wp-cli.phar --info produces no output. Just to make sure php was working properly I ran a Hello World script with php test.php and ...
0
votes
1answer
19 views

Loop stopped working

I have a huge issue and I broke my had trying to find the correct solution. I have a following loop code. This loop is inside my page-product.php file: <?php $terms = get_the_terms( ...
-2
votes
0answers
12 views

Web scraping Amazon and auto product adder to WooCommerce [on hold]

I want to make a script which can web scrape Amazon with searching products and auto add to WooCommerce.
0
votes
1answer
13 views

Redirect to another page after submission using wp_mail

I'm trying to redirect to user to another page after the form has been submitted using wp_mail. // Hooking up our functions to WordPress filters add_filter( 'wp_mail_from', 'wpb_sender_email' ); ...
0
votes
0answers
18 views

Encoding video without exec function

I use ffmpeg to encode videos that i upload to my website, it works fine but the problem is that it requires exec function on host enabled, my host provider says enabling this function is a security ...
0
votes
2answers
515 views

Dynamically Create Posts Via XML File

I'm new to wordpress/php and I'm trying to create new posts dynamically through a xml file. The xml I'm working with is this one. The file get updated periodically during the day in a FILO fashion (...
0
votes
1answer
11 views

Adding a widget under an 'Add to Cart' button through a PHP snippet

Despite that my PHP knowledge is very scarce I've managed to add some elements under the add-to-cart button in my installation of Woocommerce with the function: add_action( '...
0
votes
1answer
502 views

can't see categories in appearance-menu-categories

I have a php script that takes categories from softonic.com. It is supposed to insert these categories inside an apps category. It does it with wordpress functions. After launch my script I can see ...
0
votes
1answer
12 views

How to check if a Customizer setting is set?

I'm trying to setup a function that writes a meta tag into the header of my site. Namely, I've set up a color chooser input like this: function customizer_options($wp_customize) { $wp_customize ...
0
votes
0answers
14 views

Send Notification to all users that followed some author

I'm trying to send notifications for who followed some author when he published new post! But it always sent to only one user not to all the followers! So how can i send to all followers ids? ...
0
votes
2answers
34 views

load more button in plugin

I wrote a simple plugin which creates a post type named cryptoevent and also creates a metabox that have some custom fields, I display this post type and fields with WP_Query, now I want to display ...
0
votes
0answers
16 views

Elementor to custom wordpress page

I have a custom page that loads wordpress header and footer via get_header() and get_footer() functions, but elementor is not loaded here. How do I load elementor css/js to custom page?
0
votes
0answers
14 views

Can’t echo all coauthors in loop (coauthor plus)

I did a summary of different pages (https://www.critikat.com) with a while loop and call children of pages when they have some with a foreach, and I call the coauthors for each of them as I did in the ...
0
votes
0answers
3 views

Echo Hestia Frontpage sections on other pages

I am using Wordpress theme Hestia. This theme allows me to use some pre designed frontpage sections to design my homepage, also does the Orbit fox plugin add some extra sections to home oage all of ...
0
votes
0answers
8 views

How Can I Display Author analytics on Frontned, Visible to Author [closed]

I wanted the authors to be able to view there analytics on the frontend. The stats for all posts of author, can be displayed on back end through various, plugins, but i could not find a decent plugin, ...
0
votes
2answers
506 views

Get first comment link on the post itself

I have this function and a link to a post: <?php foreach ($results as $id) { $post = &get_post( $id->ID ); setup_postdata($post); <li><a <?php href="<?php ...
0
votes
1answer
509 views

Display PHP within HTML values

What is the correct way to display a value in a link using php? The (Advanced Custom Fields) php works correctly outside of the html. Book on Expedia.com <a class="alignright" href="<?php ...
0
votes
1answer
26 views

How to Display Search Results with any Page/Post

I'm not really sure where I should ask this question so here I am. I have a website that is split into three parts from left to right: Menu (div name "sidebar"), Center Blue (div name "center"), and ...
0
votes
1answer
540 views

Menu Custom Data Attributes

I'm trying to add a custom data attribute to the <a> element. What I'm trying to do is integrate the navigation effect in this CodePen I can do all the CSS but I need to add the HTML part such ...
0
votes
0answers
12 views

custom post type not showed with bootstrap 4 modal and template part

I've created a showcase template part that will get all my custom post_type for a showcase. The problem is that I've 18 entries added and the template part will only show 10 entries. I've used a ...
1
vote
1answer
20 views

How to display selected taxonomies by their parent

I have a custom taxonomy as 'services' and custom post type as 'portfolio'. What I would like to do is; I want to list all the selected services under their parent taxonomy in single page. This is ...
0
votes
0answers
11 views

Backend overview pages in different sections

Is it possible to edit the WordPress admin overview of pages: /wp-admin/edit.php?post_type=page into sections based on post meta values? So for example I got 3 pages with the meta value of "Planten" ...
0
votes
1answer
24 views

Cant connect to database with php 7.3

when i update my site from php 5.6 => 7.3.0 . i recviced this error 'Error establishing a database connection'.. But when i downgrade php to 5.6 , my website work fine . Anyone know this issue . this ...
0
votes
1answer
14 views

Need help with AJAX login to call php in functions.php to handle redirects based on user cap (role)

I can't find the answer for my question anywhere. I am trying to make a login redirect script, after login the user (depending on their role) will go to a certain page. I have currently a working ...