Articles of php

What exactly does “Posts page” do in WordPress?

Hay, I’m making a WordPress template, and i have 4 main pages. HOME BLOG CONTACT ABOUT US As you can see “Blog” is a page (i need it to display when i call wp_list_pages()), but how do i edit this blog page? I assigned the “Blog” page a custom temeplate (called blog.php), but when “Blog” […]

How to create post thumbnail

I am working on the WordPress Twenty Ten theme, and I want to display post thumbnails. I have followed the steps below: Added following code in functions.php file: if ( function_exists( ‘add_theme_support’ ) ) { add_theme_support( ‘post-thumbnails’ ); } I have also defined post thumbnail size, set_post_thumbnail_size( 150, 150 ); And I configured the media […]

Return array of categories to php function for current post

I am currently trying to add a list of categories that a custom post is in (only have 3 categories). by using the code below, I have managed to output ALL categories into a list but what am I missing to filter just the categories that that post is in… Been stuck for days! Here […]

Plugin exceeds memory limit

I’m bulk deleting posts from my WordPress site using the function wp_delete_post and categories using wp_delete_category. That are about 100.000 posts and 4.000 categories, and after a while I get a PHP Error PHP Fatal error: Allowed memory size of … bytes exhausted That’s what I do inside my code: // get all IDs from […]

How to generate page content from database the right way?

I am creating many pages and store them into the database. I am first styling them and than storing them. The idea is to use page.php to check the page id and display the needed post. This is all good, but I have many pages in the website. WHich means I have to perform the […]

external wordpress pages using wp-blog-header

I am setting up a few sections of a website external to the core wordpress installation, but I still want to use the built in wpdb functions, and/or header files from wordpress. I follow the instructions outlined in wordpress, setting up my headers: <? require(‘../cms/wp-blog-header.php’); define(‘WP_USE_THEMES’, false); . . ?> Everything works great. I can […]

how to get permalink structure with php

I need to make if statements for every permalink structure, so I need to know if there is a function that returns to me the actual selected permalink structure by the user. To make it simple all I need to know is if this permalink: www.site.com/?p=22; a condition will apply else if this structure www.site.com/cat/title […]

Extend a class of a plugin

There is a plugin that uses a class; and create an object like this: class WC_Disability_VAT_Exemption { public function __construct() { add_action( ‘woocommerce_after_order_notes’, array( $this, ‘exemption_field’ ) ); } public function exemption_field() { //some code here } } /** * Return instance of WC_Disability_VAT_Exemption. * * @since 1.3.3 * * @return WC_Disability_VAT_Exemption */ function wc_dve() […]

Calculations in functions.php

I’ve created an invoice theme for myself and I’m trying to get the invoice total in a custom column. I’ve tried adapting the code I’m using within the template page to display this in the functions.php file but it’s not working. I’m getting an operand error where my multiplication operand is and I don’t know […]

Customizer Show/Hide

In my Customizer, I have a checkbox to “Display Title”. I want the title to display by default (which it is in the Customizer) but the Customizer settings need to be saved in order for it to display on the live site. I would like it to display without having to save the settings first. […]