Articles of php

Trying to make a simple wordpress plugin, having difficulties understanding how to make it?

I am currently trying to develop a simple wordpress plugin for a client, but am having issues with how complicated wordpress makes its APIs and plugins. The code so far: add_action(‘admin_menu’,’pagePluginMenu’); function pagePluginMenu() { $appName = ‘Page Rebrander’; $appID = ‘page-rebrander’; add_menu_page($appName,$appName, ‘administrator’, $appID . ‘-top-level’, ‘pluginAdminScreen’); } function pluginAdminScreen() { $data = ‘<textarea rows=”50″ […]

Cannot load media and I get “PHP Warning: Invalid argument supplied for foreach(”

if I don’t have active debug mode, I can’t see any media in back end (in Media menu or even as in created gallery in a post editor). When I turn on debug mode: define(‘WP_DEBUG’, true); // Enable Debug logging to the /wp-content/debug.log file define(‘WP_DEBUG_LOG’, true); // Disable display of errors and warnings define(‘WP_DEBUG_DISPLAY’, false); […]

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 […]