The server-side programming language that the WordPress core, plugins and themes are written in.

learn more… | top users | synonyms (1)

3
votes
2answers
695 views

How do i hide the <h2> if the <h1> appears

I'm working on a WordPress site that automatically displays an h2 on the page as what the page/post is titled. I want to manually create h1 for some pages and have the h2 to be hidden if the h1 ...
3
votes
1answer
1k views

Wordpress custom taxonomy description for each post?

In a Wordpress blog, I'd like to put the term description of a specific custom taxonomy in the footer of each article. Is this possible? I've tried <?php term_description( $term_id, $taxonomy ) ?...
3
votes
2answers
815 views

WordPress as a backend only. How to output database content on public side without WordPress?

I'm a bit of a PHP MySQL newb but i feel i need to bypass WordPress for the frontend of a site i'm building (it is mainly just RSS and JSON feeds). I was wondering if there are any tutorials or advice ...
3
votes
3answers
998 views

Add Useragent to the body class?

I'm looking for a way to add body class depending on the User Agent of the client with php. I'm looking to implement it this way: page.php: <body id="front" <?php ( function_exists ( '...
3
votes
3answers
1k views

Enable/disable post revisions programmatically

Is there a way to temporarily disable revisions.... I have noticed that wp_update_post is very slow and creates revisions I don't need. The fix could be to disable revisions before issuing ...
3
votes
2answers
6k views

Inserting Gravity Form checkbox values into Advanced Custom Fields [closed]

I'm trying to feed checkbox values from a Gravity Forms form (which creates a new post) into an Advanced Custom Fields field. I've had a read around and found some info in a post (at the bottom of the ...
3
votes
2answers
1k views

remove tags from posts in php

I feel like this should be a simple question, but I can't figure it out. If I have a post_id, how can I remove a particular tag from that post in php?? I know how to update meta information, but tag ...
3
votes
2answers
386 views

PHP/Manual use of images? - 2 Questions

I've made a quick PHP script/page that uses the wp_insert_post() function to insert a post directly. And this works great. The post I am manually adding has an image in it, so I firstly manually/...
3
votes
2answers
3k views

How do I remove a require_once admin panel from the parent theme from the child theme functions.php?

In the parent theme, the following is at the bottom of the functions.php file. require_once(TEMPLATEPATH . '/admin/admin-menu.php'); In the child theme's function.php, this code will include the ...
3
votes
2answers
370 views

Getting the comment number relative to all the post's comments

Any ideas how to accomplish this? Something like this would work, but if there are threaded comments you get the wrong number, because pages with threaded comments have actually more comments than ...
3
votes
2answers
1k views

Correct Approach for Validating Custom Field Input

I have a custom post type with several custom fields. I am looking to do some validation on these fields because they will be used downstream by other services. So, it is important that it can't be ...
3
votes
1answer
164 views

Should the value of core functions be escaped before outputting?

Should the value of functions such as the_permalink() be escaped before outputting to the browser? For example, do I need to escape the following? <a href="<?php the_permalink(); ?>">Link ...
3
votes
1answer
57 views

wp_get_attachment_url filter won't accept two arguments

Here is the specification for the filter for the wp_get_attachment_url filter: /** * Filter the attachment URL. * * @since 2.1.0 * * @param string $url URL for the given attachment. * @...
3
votes
1answer
202 views

Check if a user already voted [closed]

I'm writing a Wordpress poll system. I need to check if a user already voted, show him/her a message. But i dont know exactly how can i do that! One of my solutions is that to creating a table (named ...
3
votes
1answer
728 views

Query both first_name and last_name from wp_usermeta at the same time

I'm trying to fetch both the first_name and last_name of all users at the same time, using the wpdb-object and the wp_usermeta table. I can't seem to figure out how to get both in the same query. ...
3
votes
1answer
3k views

Edit tag cloud widget number

By default, the WordPress tag cloud widget has a set amount of 45 tags to display. This can be seen in the wp-includes/category-template.php file. By default, the WooCommerce plugin which I have ...
3
votes
1answer
728 views

How to get the custom header image's alt text?

I'm using a custom header in my theme. My aim is to add an alt attribute to my custom header img element. My img element so far looks like this: <img src="<?php header_image(); ?>" height="&...
3
votes
2answers
393 views

is there a simple way to list every templates / php files used to generate a specific page?

To customize a theme , it is not always easy to trace every files that are used and find out which one do what . For example i' like to find out how my menu is generated so i can add some conditions ...
3
votes
1answer
267 views

Adding Custom Fields for Img in Posts

I'm wondering how I'd be able to set a custom field within my Wordpress posts. I want to have a field available to add an image via the Post dashboard - that has a max width & max height set, I ...
3
votes
3answers
6k views

How to set custom cookies before output

What's a surefire way to check/set cookies before the php headers are sent? Is there an action or filter that would be the best place to hook a setcookie() function?
3
votes
1answer
90 views

How to get the registered sidebar's name by its id?

Let's say I have this code in my "functions.php": function mytheme_widgets_init() { register_sidebar( array( 'name' => esc_html__( 'Sidebar Name', 'mytheme' ), 'id' ...
3
votes
1answer
225 views

the_author_posts_link css class

Currently I'm styling as project where I need to add a custom CSS to the_author_posts_link(). I want to add the class "blog-link" with the the_author_posts_link() . How do I add a css class to it?
3
votes
1answer
474 views

Check php version before theme activation

I've got theme that requires php 5.3+ version. If older - fatal error occurs with it. So what I need to do when user try to activate this theme is to check php version before going into theme code ...
3
votes
1answer
10k views

what is the use of /wp-includes/SimplePie?

I have this location on my server. /home/localhost/public_html/wp-includes/SimplePie. I have not installed samplepie plugin. What is it used for since it is not associated with samplepie plugin. The ...
3
votes
1answer
1k views

Why Can't PHPUnit UnitTest My Wordpress Website

I have been researching this issue for days and although many people ask this question I never found a clear and concise answer. I am running: PHP Unit: Version 3.7.21 WordPress: Version 3.5.1 OS: ...
3
votes
6answers
26k views

How to stop form resubmission on page refresh

Hi I have a form that adds attachments to a post, however when the form posts it obviously doesn't show the post with the new attachment echoing "your file has been uploaded". When the user refreshes ...
3
votes
2answers
767 views

How can I add dropdown widget/box to admin post page?

I am trying to figure out how to add a dropdown widget to the post page. The reason I ask is because I would like to be able to have a few different post classes that the user can select while making ...
3
votes
2answers
1k views

How to hide get_theme_mod if field empty

I'm using: get_theme_mod to show various pieces of info from the theme customizer, in the following format: <a href=" <?php get_theme_mod( $name, $default ) ?> ">This is the link</a>...
3
votes
1answer
725 views

Site Title and Tagline in Theme Options Page

I'm using the Options Framework Theme to put together an options page. The user(s) I'm building this for would like to be able to edit a few settings directly from this page, including of which - the ...
3
votes
2answers
1k views

queries inside of a class

I'm building a plugin and I'm quite new to wordpress I have a class what has couple of methods what should execute database queries. The class look as it follows class MyClass{ private $...
3
votes
1answer
349 views

Restrict users from editing post based on the age of the post

How can I restrict users (based on Capabilities) from editing their published posts after a custom amount of time. For instance, a user that can publish_posts (authors) can not edit a their post if ...
3
votes
1answer
2k views

How do I override the Message-ID header of wp_mail function?

I have a custom notification function for our comments editor, who prefers to have all comments from one article threaded together in her email client. To achieve this, I'm creating a custom message-...
3
votes
1answer
6k views

List page for custom post type?

I have created a custom post type in wordpress and have 90% of the functionality working correctly, but I am having a bit of trouble trying to create a custom listing page template. Currently it is ...
3
votes
1answer
61 views

Bypass .htaccess when using download_url

I've got the following .htaccess file in my a custom directory in Uploads called client. RewriteEngine On RewriteCond %{HTTP_REFERER} !(www.)?example.co.uk/client-area* RewriteRule ^.*$ - [R=403,L] ...
3
votes
1answer
122 views

Displaying post per day

Currently I have the code displayed below. <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <div class="col-lg-3 col-md-4 col-sm-6 col-xs-12"> <a class="...
3
votes
1answer
156 views

Walker class: Problems with understanding how walk() method can be called without error

I am struggling with understanding how WordPress uses the Walker class. In particular, I don't understand the walk() method (I think). First, let me explain what I understood: When calling ...
3
votes
1answer
232 views

How to get the post count for the last x days filtering by categories

How can I get the posts count for eg the last 4 days, but only for specific categories eg. (1,2,3)? Thanks in advance.
3
votes
1answer
648 views

Modify image while uploading

I have a plugin which uploads image using wp_upload_handler here is a function: //handles upload, a modified version of bp_core_avatar_handle_upload(from bp-core/bp-core-avatars.php) function ...
3
votes
1answer
152 views

Using Global Variables Expensive for PHP

I am writing some functions to display Custom Fields across multiple templates. Rather than getting each CF like so: $var = get_post_meta($post->ID, 'my_cf_key', true); and then checking if the ...
3
votes
1answer
795 views

How to use multiple query with same meta key

I use these codes to print custom field query. My custom field key is out_wiki <?php if( get_post_meta($post->ID, "out_wiki", true) ): ?> <div class="outlink"> ...
3
votes
1answer
930 views

Rewriting search and pagination base

After trying for weeks now how to find a working solution I got rid of most of my functions and trials and just left the pagination function underneath in my functions.phh file: /** * Pagination ...
3
votes
2answers
2k views

How do I create a WP user outside of Wordpress and auto login?

I've built a directory of members on a non-WP site (using php and mysql). Each member can log in and update their details using a username and password. I want to be able to get this to automatically ...
3
votes
2answers
89 views

Wordpress will not operate correctly

My website is ImASpy.com. If you click on the link, Findings, this takes you to my first Wordpress page. It appears to work fine until you click on comments, or you try to go to the about page, which ...
3
votes
1answer
2k views

difference between esc_attr(), strip_slashes(), strip_tags()?

So what's the difference between these, and when should we use each one? Is esc_attr() safe enough to escape any type of data you get from the user ?
3
votes
2answers
50 views

How do I output a database option that is an array into a get_posts array?

This must be fairly simple, but I'm puzzled. And I may be going about it backwards. How do I output a database option that is an array into a get_posts array? I have an option in the database that ...
3
votes
2answers
101 views

wp_insert_user role not working

I have be trying this all day but it is not working how do I set a role for the current user I am inserting with the wp_insert_user() function $userdata = array( 'user_login' => $username, '...
3
votes
1answer
82 views

Modify Maximum upload file size text

I have an issue with user uploading large images. I have prevented this with this snippet... add_filter('wp_handle_upload_prefilter', 'f711_image_size_prevent'); function f711_image_size_prevent($...
3
votes
1answer
41 views

Wrap each shortcode in array to div

i'm trying to wrap each shortcode in div with special data attributes, but when i'm using nested shortcode they don't wrapped, where i'm wrong? thanks public function wrapShortcode( $content ) { ...
3
votes
3answers
85 views

How can I change Wordpress domain from remote to localhost?

I recently had a system crash and had to reinstall WordPress with my backup files. In the JavaScript log I began throwing errors pertaining to the domain and realized I was still using the remote ...
3
votes
1answer
108 views

Detect a focus on wp_editor

I wan't to detect/callback when a wp_editor(..) output text-area/content-editable is focus. Quite a simple question that I could not find anywhere. <div class="compose-body"> <?php $...