Articles of php

Custom Post Type Plugin not loading category template and loading 404 instead

I have been looking around for the past few hours and I am starting to be kind of desperate… I have created a plugin to add my custom post type “project” (making a new portfolio)… In this plugin, I have the function file, and a template file single-project.php and also a template part folder with […]

How to display meta_value array?

I’m trying to put together a list of all posts where the metadata matches a specific query. It appears to work fine until I try to output the data, at which point it is repeated continuously. I expected it to display 16 23 but instead it shows 16 23 16 23 16 23 16 23 […]

Logic on a Gravity Forms redirect

I’m setting up a series of questions and based on the answers, I am trying to redirect to a specific page. For one example, the questions have to be answer correctly, they need to be male and 65 or older. For the other, correct questions, they need to be female and 55 or older. Here […]

Why my query does not run with prepare

Hi Below is my query and it works with prepare keyword on the localhost but whenever I use prepare keyword with my queries on live server the data does not show up and as soon I remove prepare from query on live server the query works. So I did this to save my site from […]

How to add new CSS file to new PHP file

I’ve made a new template file for WordPress constructing the elements of the page via PHP and WordPress recognizes the template as such. Then I wanted to include a CSS file for said template (same folder) and went with the standard: <link rel=”stylesheet” type=”text/css” href=”style.css”> but for some reason the PHP file does not load […]

How do I check if there is a tag in the title

I have many post with multiple tags ex: AMOS LEE, FOO FIGHTERS,TAYLOR SWIFT Post only have one of the tags in the title ex: “The Man Who Wants You” – Amos Lee How would I scan the_title() and go through the tags and store the matching tag in a variable? Ive tried <?php $id = […]

Using Cookie Data For WP_Query Loop

I’m trying to retrieve data set in a cookie and use this to run a query. I’ve set the cookie in functions.php like so; add_action( ‘init’, ‘resultsCookie’ ); function resultsCookie() { setcookie( ‘your-results’, ‘18,17,11,8,10,27,26’, time() + 3600, COOKIEPATH, COOKIE_DOMAIN ); } While I can echo the string, I can’t seem to get this functioning within […]

get_post orderby not working in plugin

Please take a look at the loops below, I’m having issues trying to order the attachment by title, name, and modified. <?php foreach ($instance[‘data’] as $id) : $args = array( ‘include’ => $id, ‘post_type’ => ‘attachment’, ‘posts_per_page’ => -1, ‘post_status’ => ‘any’, ‘orderby’ => ‘title’, ‘order’ => ‘DESC’, ); $data_attach = get_posts($args); foreach ($data_attach as […]

GravityForms Limit Submission Per Time Period by User or IP by 30 minutes?

I am following this DIY code by GravityWiz but the author doesn’t mention how to make the code work with 30 minutes, 1 hour, 2 hours, etc…? He only explains how to make it work with 24 hours – When looking at the code here – Does this mean I make the functions: […]

WooCommerce “Checkout Now” button

Okay so I want to add an additional button to the single product page that says “Checkout Now”. This checkout now button should go directly to the checkout page, not the cart page (like the regular “add to cart” button). I can’t for the life of me figure out how to get this done. I’ve […]