A function is a sequence of program instructions that perform a specific task. It is packaged as a unit that can be used wherever the according task should be performed.

learn more… | top users | synonyms (2)

0
votes
0answers
3 views

mb_substr() function doesn't seem to work

I have a profile field (multi-line text box) for users to enter a bio. For display on the member directory (via a BuddyPress theme), the bio should be truncated to 140 characters. I created a ...
0
votes
1answer
12 views

Unable to Call More than One Meta Box Output

I have a custom meta box with multiple text fields. I use this to call the information in the first box: <?php the_post(); echo get_post_meta( get_the_ID(), 'dbt_text', true ); ?> And this to ...
-1
votes
0answers
8 views

wordpress filter function to change a string

I want to change word "one" to always be output as word "two", I want it to change on just the admin level AKA:theme options. I'm currently looking at a str_replace() function to replace the string ...
8
votes
3answers
993 views

How to change the case of all post titles to “Title Case”

I am helping my father with his WordPress website. It has over 1,700 posts with TITLES IN UPPERCASE. We'd like to change these to "Title Case" in the database (possibly using this PHP script). The ...
0
votes
1answer
321 views

Pass a Select List Value into Functions.php function Tax Query Array

Hoping someone can assist as I am very new to the whole functions.php/wordpress coding side of things but I basically have the following use case that I am trying to achieve through the use of Gravity ...
0
votes
0answers
11 views

Change Wordpress Gallery Markup in functions.php

I'm looking to change the markup of the Wordpress Gallery, so that it outputs a new set of code. Ideally, this is what I want (a Bootstrap-based markup). <div class="col-md-3 col-sm-4"> ...
2
votes
1answer
1k views

Problem using is_single() to enqueue script from functions.php

I'm having trouble only adding scripts to single post pages. I need to both include and exclude certain scripts using is_single() but it doesn't work either way I try it. I have the template tag on ...
2
votes
2answers
229 views

Find first image on paginated post for Pinterest

I've been looking for days, yet can't find a good answer. Perhaps the SE crowd can be of assistance. Any help is much appreciated. I am using a custom-coded pinterest button included on posts that ...
0
votes
1answer
18 views

Changing plugin options from theme functions file?

I am making a starting-point Wordpress theme that will be used on dev projects. In this theme, I am automating common plugin installs that are used on every project. I have been able to automate ...
1
vote
2answers
111 views

Create Logout Link Wordpress Admin Menu

I'm looking at creating a Logout link in the Wordpress admin menu that when clicked the user is logged out immediately. I don't want the Logout link to be a submenu of an existing menu, I just want ...
0
votes
2answers
22 views

Dynamic body classes based on current page

Is there a way to add classes to the body_class function based on the current page? For example if you're on the homepage, as well as the usual generated classes, the <body> element would also ...
1
vote
3answers
2k views

Load post with a different template?

Let's say I have a single.php file with a certain layout (graphic intensive). I want to create a sort of plain-text version of the same page that is only called when the user clicks the provided ...
0
votes
0answers
15 views

How to get the link of each category? [on hold]

I have tried this code: <?php $cats = get_categories(); foreach ($cats as $cat) { $cat_id = $cat->term_id; echo '<div ...
1
vote
1answer
565 views

Using PHP to toggle stylesheet and header image, set in cookie

I haven't done a lot of work with cookies or Wordpress before so I think I've been a bit over-optimistic in my quest :p I have created two themes for my site, night and day. I would like the user to ...
-1
votes
2answers
29 views

Getting URL of archive (category) page

I'm trying to retrieve the current URL of the page, which works everywhere except for archive pages, for example, a category page. On a category page, it shows as the most recent post in that ...
1
vote
1answer
46 views

What's the point of using Wordpress's built in admin-ajax.php?

I'm trying to understand why using admin-ajax.php is advantageous over doing something like this: add_action ('wp_loaded', 'my_ajax'); function my_ajax() { // Do Ajax, Check $_POST die(); } ...
0
votes
1answer
21 views

Query function not executed between <div> element [on hold]

I'm wondering why the following code is not executed between the element it's put in. I know sort of how to fix, but I'm not sure if that's the best solution. My code: First function function ...
0
votes
2answers
16 views

Wordpress - registering sidebar and adding a button directly after .textwidget

I have registered a new widget area, code as below and want to add a button after the .textwidget, however cannot seem to do it properly. Adding it after the </li> results in the button not ...
1
vote
2answers
258 views

Dynamically add id to heading tags

How do I add an id attribute dynamically to every heading tag on a wordpress website using php? I wanted to make it so that for every heading tag (h1, h2, h3, h4, h5, h6) I have a unique id attached ...
0
votes
1answer
37 views

What exactly do this function declared into functions.php file of a WP theme?

someone can help me to understand what exactly do this function declared into the functions.php file of a theme? function exclude_featured_tag( $query ) { if ( $query->is_home() && ...
0
votes
1answer
10 views

update_usermeta don't work

When I return in the function $setfound, I become a white screen and when I return $setlink, it works fine. function editsteamlink(){ $setlink = $_POST['steamlink']."/?xml=1"; $setresponse = ...
2
votes
1answer
4k views

Using wp_get_nav_menu_items() to list children of children pages

I'm working with a Genesis Based Theme and I'd like build a Page/ Child Page menu structure. That part I can do with the help of some code produced by Bill Erickson. Essentially what I'm trying to do ...
0
votes
1answer
19 views

is_dynamic_sidebar always returns true while using Jetpack visibility

If I have any widgets in the sidebar, even if the jetpack visibility is set to not show on that page, is_dynamic_sidebar return true. Here's the code in my theme functions file: add_action( 'init', ...
0
votes
2answers
26 views

jQuery HoverIntent is not a function

I am working on a site that uses jQuery for a number of functions but I am having a repeating error: hoverIntent is not a function I have referenced similar questions on this forum and they ...
0
votes
1answer
246 views

Using add_filter() in Widgets

Just have a query reference the add_filter() function. Can you use this function inside a WordPress widget class. Example I have a widget with dynamic created code that I want to pass to another ...
0
votes
0answers
10 views

Creating multiple functions for front-end forms

I have the following situation (which I simplified for didactical purposes): page-books.php: <form> <input type="text" name="title" /> <input type="text" name="sinopsis" /> ...
0
votes
0answers
18 views

Different Name and Email for wp_mail_from and wp_mail_from_name

I want to make the email and Name dynamic.Everything works fine.But I can't able to get the name and email for each doctors.I have attached my code which I have tried.please help Thanks in Advance. ...
-1
votes
2answers
284 views

How to pass hook variable to function?

I have a function that has an add_action inside it that calls the user_register hook. I would like to be able to echo the variable $user_id from the user_register hook and the $_POST array as well. ...
1
vote
2answers
354 views

Using plugin functionality in external php script not working

I am encountering a strange problem which I couldn't solve so far. I'm calling a .php script via cronjob (Debian/GNU Linux). To use wordpress functionailty I added: define('WP_USE_THEMES', false); ...
1
vote
0answers
40 views

wp-comments-post.php file returns a blank page

When i post a reply to my blog, it's return a blank page to me. It seems that happens because of this code in wp-comments-post.php if ( 'POST' != $_SERVER['REQUEST_METHOD'] ) { header('Allow: ...
0
votes
1answer
29 views

get_post_meta not working inside a function in functions.php but works outside

function notify_new_posts($post_id) { $keyval = get_post_meta( $post_id); $buyer_wdistance = get_post_meta( $post_id, 'cf_wdrive'); //$buyer_wdistance = $keyval['cf_wdrive'][0]; ...
0
votes
1answer
31 views

Replace admin header logo with an image

I want to replace the default WordPress admin bar logo to my custom logo which is a PNG file. I have tried a code it's not working. function custom_logo_admin_header() { echo ' <style ...
1
vote
1answer
242 views

Function to wrap the_content in a div

Whenever I've developing a new theme I always wrap the_content in a div, like so; <div class="entry-content"> <?php the_content();?> </div> Is there a way I can streamline ...
0
votes
1answer
484 views

Only let plugin add actions to wp_head & wp_footer on single posts

I'm using a a plugin (Comments Evolved) on a recently built site. The issue I'm having is that this plugin globally enqueueing and adding actions to the head and footer of all pages. I'd like to ...
1
vote
2answers
497 views

Update user meta of author when post content is viewed

I have a value that I'm trying to store as user meta for authors on my site. I need it to update itself every time the content of a post is viewed for that author. Here's as far as I've gotten but it ...
1
vote
1answer
33 views

How to add a class to the attachment images

When I'm in the Wordpress editor and I add an external image with the 'img' button, my html result wil be like this: <img src="http://example.com/image.jpg" alt="image" /> How can ...
0
votes
1answer
40 views

Display WordPress Search

I am trying to display the current WordPress search term on single.php, index.php, and category.php...basically when someone searches for something I'd like WordPress to remember what the last search ...
0
votes
0answers
13 views

Move Custom Fields on General Settings Page to New Location

I've created some custom fields on the General Settings page after studying up on this post: Add multiple custom fields to the general settings page. I'd really like to move them to their own ...
0
votes
0answers
9 views

Getting categories from DataBase & WP Favorite Post

I am trying to create a shortcode that pull the most saved posts (using WP Favorite Post) and displaying them by YEAR, MONTH or CATEGORY. So far I have been able to get the year and month working ...
1
vote
1answer
54 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 ...
1
vote
1answer
25 views

Child theme within a child theme?

I'm developing a child theme, but also want to make it possible for that child theme to have a custom functions.php file that won't be overwritten during theme updates .. is this possible in any ...
2
votes
1answer
2k views

plugins_url vs plugin_dir_url

Im seeing WordPress plugins either use plugins_url or plugin_dir_url when creating constants to some of their folders. Is one better than the other? examples: define( 'MEMBERS_URI', trailingslashit( ...
1
vote
1answer
287 views

Changing post category from dropdown

I am showing a list of posts on the front of my wordpress site which each have a dropdown next to them with a list of category's, which are pulled in as follows. As you can see the form submit button ...
0
votes
1answer
46 views

Passing postid of Testimonial Custom Post in Shortcode Parameter

I am trying to create Testimonial custom post and display using shortcode function create_post_type() { register_post_type( 'testimonials',//new post type array( ...
1
vote
1answer
821 views

edit role display name and label name without plugins

I'am creating WordPress function for editing role name function change_role_name($role_name, $new_role_name, $display_name) { global $wp_roles; if ( ! isset( $wp_roles ) ) $wp_roles ...
4
votes
5answers
2k views

Is it possible to rename a post format?

Since WP 3.1, it's been possible to use Tumblr-style post formats. I want to use the 'aside' option in a theme, but I want it to have a different title in the WP admin area. So, for example, when a ...
0
votes
1answer
17 views

Get all categories of custom post even not assigned

I know how to get all categories with get_categories and name custom taxonomy name, but wordpress only shows those categories those are assigned to a post. Those which are created, but not assigned, ...
0
votes
1answer
27 views

Can't get link if there is no post available

I have a function which creates a link for the taxonomy term , with the selection of post_type. function get_custom_term_link( $term, $taxonomy, $post_type ){ $link = get_term_link( $term, ...
0
votes
0answers
18 views

Why does `url_to_postid` return 0 when testing `page_for_posts` Page?

If I set Reading Settings > Posts Page (in other words, the page_for_posts option) to a static page, and then attempt to pass its URL through url_to_postid() it will return 0 - why is it? I ...
2
votes
2answers
43 views

Calculate percentage of post by category

Is it possible to calculate the percentage of posts in each given category? I'd like to make a bar chart to visualize the amout of posts in those categories. I thought what one needs would be the ...