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
1answer
338 views

Linking Javascript in functions.php file

Below is my raw javascript embeds from my html template. But I cannnot figure out exactly how to add it to my functions.php file. It seems pretty difficult. Can you please assist with the correct ...
1
vote
3answers
427 views

How to check if a user exists by a given id

Is there any way to check if a user id exists? I want to create a function similar to username_exists() but which returns if the id exists or not.
0
votes
1answer
28 views

Excerpt function for any content

Is there an excerpt output function in wordpress I can hook into regardless of the field used, rather than just the main content field? I have a CPT using custom fields, and rather than creating a ...
1
vote
1answer
2k views

How to create TEMPORARY Download links in a wordpress POST?

I'm creating a WordPress blog with some members-only page. In those members-only posts I have my own tutorial download links which i have uploaded for FREE. Problem is I want them to stop sharing the ...
0
votes
1answer
32 views

Problem in shortcode outputting content

I`m trying to make a shortcode that output the a div containing content from Custom Post type . I'm able to output the content but content does not output within div . the shortcode output the div and ...
0
votes
1answer
28 views

How do I display a date correctly that is stored in the database as a backwards 8 digit number from Advanced Custom Fields? [closed]

I am modifying someone's Wordpress theme and they have a section for upcoming tour dates. The page for inputting was made with Advanced Custom fields plugin and uses a date picker widget that stores ...
0
votes
1answer
17 views

How to convert raw url to hyperlink?

I have a custom field with raw urls and I want to convert them to hyperlinks. So I used this code: <?php $text = get_post_meta( get_the_ID(), 'Links', TRUE ); echo make_clickable( $text ); ?> ...
0
votes
3answers
94 views

Dequeue script to prevent javascript event conflict on wordpress child theme

I've built a child theme of Divi Theme to use with Buddypress. So far so good, except for a script conflict on commenting buttons. The theme load a javascript (js/custom.js at 2642:2662) with the ...
2
votes
3answers
2k views

Add class to menu items of one specific menu (nav_menu_css_class)

This code adds an extra class to all my menu items: add_filter('nav_menu_css_class' , 'special_nav_class' , 10 , 2); function special_nav_class($classes, $item){ $classes[] = 'btn'; return ...
1
vote
1answer
452 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 ...
-4
votes
1answer
1k views

How I can show short content with short tag

I am using Wordpress and I want to show ** short content with limit ** of words for every post on home page and for this I am using this code functions.php function abc_the_content($num_words) { ...
0
votes
1answer
20 views

Randomize Color Scheme Selection in Theme

on my site I'm using cenetric, a child theme of genesis and this theme comes with some predefined color schemes. //* Add support for additional color style options add_theme_support( ...
0
votes
1answer
43 views

Insert function insde body tag

How to insert this function inside <body> <?php function Ciusan_NBar(){ global $options; $options = get_option('Ciusan_NBar'); if($options['CNB_Showing']=='yes'){ ?> <div ...
0
votes
1answer
40 views

Is there any wordpress function to update a random post every 10 minutes?

I' m looking for a function which can be inserted in wordpress theme function.php , when inserted , i want it to update a random post (which is already posted ) every 10 minutes . can this be done ...
0
votes
1answer
75 views

How to build shortcode for tabs

i made a tabbed widget to display recent post , comments, and popular posts, but now i want to take out tab function from this and make a shortcode of it, so i can add it to wp posts and use it there. ...
2
votes
2answers
693 views

How to customize the_archive_title()?

In my child theme's archive.php, I have the following code for displaying the title of my archive pages: <?php the_archive_title( '<h1 class="page-title">', '</h1>' ); ...
1
vote
1answer
129 views

Remove “Category:”, “Tag:”, “Author:” from the_archive_title

I have the following code in my theme's archive.php: <?php the_archive_title( '<h1 class="page-title">', '</h1>' ); ?> This gives me titles like "Category: Russia", "Tag: ...
0
votes
1answer
21 views

Excerpt for pages not showing

I am creating a simple wordpress theme and need excerpts for pages. I have tried the code from many topics some resolved on 'wordpress SO' but nothing works. Because I created the theme from scratch ...
0
votes
0answers
37 views

Restrict Editing by Category

I've tried every possible user role plugin for this, but each of them no longer work with the latest edition of Wordpress (Role Scraper, Restrict Categories, Advanced Access Manager, etc). If a plugin ...
0
votes
1answer
18 views

Emailing Authors When Post Is Published

I have gotten the code to do this. However the theme I am working with does not save emails the authors input on the front end into the normal wordpress email. It instead saves it in a variable. ...
0
votes
2answers
197 views

Possible to register multiple custom taxonomies in one function?

I'm registering 7 custom taxonomies in my functions.php. Since each function uses the same labels and arguments and is attached to the same Custom Post Type, I'm wondering if it's possible to register ...
0
votes
0answers
21 views

Custom function to add a secondary logo

I'm looking to create a custom function in order to be able to change/load a new image from the "customize" panel (this because I won't be the one who manage the website, so I'm trying to made things ...
0
votes
0answers
19 views

Rotate image media item 90° anti/clockwise ajax front end function?

Is there a rotate image function that I can create a button on the front end of my website, using ajax inconjuction with the id number of the media item? I'm thinking having 2 buttons, rotate left ...
0
votes
2answers
27 views

Assign category a default post type

This one has been bothering me for a few days now, so I'd really appreciate any help you can give me. Problem overview: I have a plugin which automatically creates a post and assigns the category ...
0
votes
1answer
43 views

Shortcode to get featured image of specific id post

So I'm trying to create a shortcode to get specific id and its featured image to display it in a specific page. I want to use shortcode to make it easier for the user to add any post in this page. ...
1
vote
1answer
984 views

Remove wp-mediaelement.css from wp_head

I´m customizing the new core audio/video player via CSS in my styles.css. I tried to remove the wp-mediaelement.css with the following code in functions.php, because I don´t need it anymore. function ...
0
votes
0answers
34 views

Modify shortcode to work with custom taxonomies and slugs

I am using this code which works fine with posts but I am looking to modify it so that the user can specify in the shortcode: custom post type name taxonomy name slug of taxonomy category For some ...
0
votes
1answer
100 views

Calling the first & last post by category in custom post type

I have custom post type for comics, called “comic” and have written a basic comic navigation. First —previous — (current) title — next — and last comic. In functions.php, this code calls for the ...
0
votes
0answers
41 views

Override A Plugin Variable And Function Via Functions.php

Is it possible to override a variable in a plugin function without altering the plugin? The closest thread I found to answer this problem is this one : Pass A Value From Outside To A Plugin Variable ...
1
vote
1answer
2k views

Set posts of a custom post type to be private by default?

Say I created a custom post type called 'Private Posts' ($post_type = itsme_private_posts) and want all posts under the custom post type to be set to 'Private' automatically when published i.e. by ...
0
votes
1answer
126 views

Fatal error: Call to undefined function add_action() - an untouched problem

The question was asked many times in many ways, but unfortunately is not covered well in most of the answers. I'm having the same issue doing things using include-files. In my TwentyFourteen child ...
0
votes
1answer
1k views

Let users upload image(s) to the post from front end

I want to enable logged in users (Wordpress) to submit posts from front end (among with other data). My form is working great, I add custom post meta data which I later display on custom post page. ...
0
votes
1answer
47 views

Can't wrap my head around this function - any help would be appreciated

OK so I am working on a theme that utilizes the customizer a lot. When you change a color for example, the necessary css gets added to the header, but when you click default, the css with the default ...
1
vote
1answer
30 views

Toggle User Roles with button

I don't know if this is possible, but I've got two user roles: Hero and Legend. When people subscribe to my website, they're assigned the Hero user role. I would like to be able to toggle users to ...
5
votes
4answers
4k views

Passing arguments to a admin menu page callback?

Situation: I'm working on a plugin and I'm developing it as a class, everything worked fine until I run into this situation. I wanted to make things a bit cleaner and tried this.. class MyPlugin { ...
1
vote
3answers
412 views

How to override core is_ssl() function?

I am looking to override a function in functions.php through a theme or plugin. Specifically, is_ssl(), which does not have any filter or action hooks. Obviously, the easy why would be to update ...
0
votes
1answer
17 views

Must filter functions receive all arguments passed to them?

I'm writing a filter function to redirect logins: function my_filter_func( $redirect_to, $requested_redirect_to, $user) { // My code. } add_filter( 'login_redirect', 'my_filter_func', 10, 3 ); ...
2
votes
1answer
384 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
15 views

Hiding all posts/products/pages from a site based on a custom taxonomy/domain name

I'm working on a site that's running Domain Theme Mapper (http://codecanyon.net/item/domain-and-theme-mapper) with WooCommerce to present two sites with two different child themes... that share a ...
0
votes
1answer
37 views

Styling admin page rows in order of importance (checkboxes)

I am altering a plugin's admin area and adding a checkbox for a "Coming Soon" option. As of now, when the user checks the "Coming Soon" checkbox, the entire row will turn green, but there is also the ...
0
votes
1answer
69 views

wpautop - disable <br> tags, keep <p> tags

I write My articles in Emacs and they end up having tons of newlines, with double newlines to separate paragraphs. Ideally, I want wordpress to work like markup does, meaning it ignores single line ...
0
votes
0answers
30 views

Load a Child Theme's style.css just before the closing </head> tag

I have this in functions.php: <?php /* Import parent style - The new standard Wordpress way - No @import in CSS! */ add_action( 'wp_enqueue_scripts', 'theme_enqueue_parent_styles' ); function ...
0
votes
1answer
76 views

Custom Taxonomy Select Menu: Setting default option value?

I'm creating a series of select drop down menus that pull data from various taxonomies. I got this PHP script working for a WooCommerce attribute of color: function get_color_dropdown($taxonomies, ...
0
votes
2answers
64 views

Load CSS conditional on custom field is present

In my functions.php I would like to enqueue a CSS file conditional on whether a custom field exists on the page or custom post type. How should I go about this? function flatsome_scripts() { ...
3
votes
1answer
766 views

Check if post is being published for the first time, or is an already published post being updated

I am building an add-on to an events module that checks for availability, since there wasn't a function for that in that module. Now that I have built the logic, there are three emails I will need to ...
1
vote
1answer
33 views

Assigning WP functions which echo to PHP variables

I am creating a settings page. If I use the default example it works fine. <form method="post" action="options.php"> <?php if(isset( $_GET['settings-updated'])) { ?> <div ...
0
votes
1answer
297 views

call wp_insert_user in custom class doesnt work

im creating a custom class to manage users in wordpress and chamilo but this is not the point. Class looks like this: class Platform { private $security_key = '..'; private $secret_key; ...
0
votes
1answer
21 views

Child theme - overriding add_image_size by a child theme [duplicate]

I am trying to get my child theme to work and to overide one line of code in the main theme functions.php but I can not getting to work since I am totally green in php. In my main theme functions.php ...
1
vote
1answer
44 views

Usage of theme name in functions

I've been studying some functions.php files to get my head around theme development, and I keep stumbling upon a reference to the theme name inside functions. Something like this: <?php ...
0
votes
1answer
34 views

Split single-review.php to two parts

I have a created a new page template which I want to use for my custom post types as well. I need to retain the existing format of my old custom post types but for any new custom post types, I want ...