Articles of php

Add category to body class

I want to add the currenty category to the body class. How do I need to modify my current code, to add also the current category as a body class to the is_singular( ‘knowledgebase’ ) section? My current code looks like this: function add_body_class( $classes ) { global $pakb; if( is_page( $pakb->get( ‘kb_page’ ) ) […]

Store and Work with huge array in WP

I need to get all terms that have post with dates in custom field. So I need a list for all dates from the term. I need to know exactly what is tha dates within each term in my site. It’s not in term, it’s in their posts. after that I need to know foreach […]

Locating Global Variables

I am now the admin of our company site using WordPress. We’d like to change some things on the home page, but unfortunately the items we want to change seem to be built in to the theme. I want to change the text overlay of our image slider. I’ve found the HTML that displays the […]

Can't get order_by meta_value_num to work properly

This query is working ALMOST as intended, but for some reason I can’t get it to order by the custom field opl_submission_tempo. That field is set up to be a number, so I’m not sure where I went wrong here. $tempo_query = new WP_Query( array( ‘post_type’ => ‘opl_tempo_submission’, ‘order_by’ => ‘meta_value_num’, ‘meta_key’ => ‘opl_submission_tempo’, ‘order’ […]

Setting All Drafts to 'exclude-from-catalog' in WooCommerce

Is there anyway to do this programatically? Meaning via a PHP script on my localhost, exporting and then importing back in– or any other way that would work. Here’s what I’m talking about: The table wp_terms is where I found the exclude-from-catalog term_id I’ve tested one product page out on the backend, and then did […]

Trying to make php run in a post

I’m trying to make this php code run in a post. Using a plugin to enable the php to run. Problem is I can’t seem to get it to work no matter how I structure the statements :/ I’m sure it’s something simple but I’m just not familiar enough with php yet to figure it […]

How to remove xmlns on language_attributes()?

Hello I’am getting this error on w3c because xmlns is deprecated. How can I remove xmlns? Attribute xmlns:fb not allowed here <html lang=”en-US” xmlns:fb=”http://ogp.me/ns/fb#” xmlns:addthis=”http://www.addthis.com/help/api-spec” prefix=”og: http://ogp.me/ns#”> My code is <html <?php language_attributes(); ?>> function get_language_attributes( $doctype = ‘html’ ) { $attributes = array(); if ( function_exists( ‘is_rtl’ ) && is_rtl() ) $attributes[] = ‘dir=”rtl”‘; […]

Echo a hierarchical list of post data from custom fields

I have a custom post type ‘locations’, with custom fields ‘State’, ‘City’, ‘Address’, and ‘Phone’. I would like to query these fields in an organized list. Let’s say I have these three posts: City: Los Angeles; State: California; Address: 123 Main St.; Phone: 888-111-2222 City: San Jose; State: California; Address: 55 1st St.; Phone: 888-333-4444 […]

Batch update a post meta field value of each post in Post Type

I need some help on making a batch post meta updater I’m trying to add to my options/setting page. Basically I’m looking for a way to click a button a batch runs through all post of a selected CPT “listings” and updates a meta field as well as run a function. Does my code look […]

Multiple WordPress Menus that will only display all pages

This is my first questions, so go easy on me! I am developing a website where the logo is placed in the middle of the navigation. I am using Bootstrap and WordPress to achieve this menu, but am running into a strange issue. Although I have “Automatically add new top-level pages” unchecked on both menus, […]