Are you the publisher? Claim or contact us about this channel

Embed this content in your HTML


Report adult content:

click to rate:

Account: (login)

More Channels


Channel Catalog

Channel Description:

WordPress › Support

older | 1 | .... | 364 | 365 | (Page 366) | 367 | 368 | .... | 413 | newer

    0 0


    I have a variable called 'today' and I'm using this to list events on date. I have added a custom meta field called 'event-days' to add extra days to variable 'today'.

    But it doesn't work.
    Note: it's located outside the loop and that's why I call the wp_query for the 'event_days'.

    global $wp_query;
    $postid = $wp_query->post->ID;
    $event_days = get_post_meta( $postid, 'event-days', true );
    $now = strtotime('today');
    if ($event_days == 'two') {
    	$today = strtotime($now . "+1 day");
    } else if ($event_days == 'three') {
    	$today = strtotime($now . "+2 days");
    } else if ($event_days == 'four') {
    	$today = strtotime($now . "+3 days");
    } else {
    	$today = strtotime('today');

    Suggestions? I think it might has something to do with being outside the loop.


    0 0


    I wrote this code in "functions.php" , but not work.

    function custom_render_title_tag($query)
    	if(is_search() || $query->is_search || is_page_template('search.php'))
    		remove_action('wp_head', '_wp_render_title_tag', 1);
            	echo "<title>The Changed Title</title>\n";
    add_action('wp_head', 'custom_render_title_tag',1);

    Then I inserted another code to get the name of the template.

    global $template;
    $template_name = basename($template, '.php');
    echo $template_name . "/n";

    But it is not work, either. ($template_name is NULL.)

    So in this timing, cannot functions.php get the information of templates? Therefore "is_search()" and "is_page_template('search.php')" are not work?

    Would you give me any suggestion or resolves?



    Anyway, I posted a nearly topic in ja.forums.

    0 0

    I used in my option page, to style it:

    function easydm_add_link_tag_to_head() {
    	wp_enqueue_style( 'easydm-style', '/'.EASYDM_CSS_PATH.'style.css', array(), null, 'all' );
    	wp_enqueue_style( 'easydm-manager', '/'.EASYDM_CSS_PATH.'manager.css', array(), null, 'all' );
    - - - - - -
    add_action( 'admin_enqueue_scripts', 'easydm_add_link_tag_to_head' );

    Now I'm trying to do the same but with JS files but this doesn't work:

    function easydm_add_script_tag_to_head() {
    	wp_enqueue_script( 'easydm-file-ui', '/'.EASYDM_JS_PATH.'file-manager.js' );
    - - - - - - -
    add_action( 'admin_enqueue_scripts', 'easydm_add_script_tag_to_head' );

    What is my mistake? Some other way to follow?

    0 0

    Hi. I'm trying to write a simple plugin to redirect a user to their home site on a multisite if they log in on a multisite. So basically if they go to and login, I want them to be redirected to the multisite they registered to (their source domain) so like

    This is what I have:

    add_filter( 'login_redirect', 'send_subscribers_home', 10, 3 );
    function send_subscribers_home( $location, $request, $user ) {
        global $user;
        if ( isset( $user->roles ) && is_array( $user->roles ) ) {
            if ( in_array( 'customer', $user->roles ) ) {
    			$user_ID = get_current_user_id();
    			$homeRedirect = get_user_meta($user_ID, 'source_domain');
    			$homeRedirectFinal = json_encode($homeRedirect);
                return $homeRedirectFinal;
            } else {
                return $redirect_to;

    So basically I'm intercepting the login_redirect filter, checking if the user is in a certain group, and if so, grabbing the website they originally registered to (in this case it will be a subdomain) and redirecting that.

    I've never written a WordPress plugin before. Anyways the problem is that this returns "" as a web page, and obviously throws a 404. Does anyone know if I can change how WordPress parses this address (so it's not as a page of the main site, but rather just an external URL) without modifying wp-login.php ?


    0 0

    Hi I am trying to change the font colour to black and actually move the form down a bit so all the form is visible. I am using Make theme and a child theme that I copy and paste into. I have tried so many different codes that I have seen listed in these forums but nothing works. Any help would be appreciated website is

    0 0

    Hi everbody,

    I created a new ‘gender’ taxonomy, for which I automatically registered the terms ‘men’ and ‘women’. For this new taxonomy I needed to create a custom metabox with checkboxes for every term of the gender taxonomy because of the user experience (the option to choose a gender (or multiple) for each post is very important for the site I’m working on, so it has to be quick and easy to do).

    This is all working just fine (code below), but I can’t seem to find a way to save the settings from the checkboxes. I’ve tried many things, eventually I got it working with ‘tax_input[gender][]’ but with the massive drawback that when editing the post you can’t uncheck all checkboxes because that won't save the new setting. Thats because unchecked checkboxes do not send any data to the $_POST event.

    So I’ve tried to create a save function hooked into ‘save_post’ (code below), but so far that didn’t work out. Does anybody have a idea how to make this work?, thanks in advance.

    — Wessel

    The codes:

    - Metabox callback:
    Echo's all terms registered for the 'gender' taxonomy (this works except saving the settings)

    function meta_gender_callback($post) {
    	wp_nonce_field(basename(__FILE__), 'meta_gender_nonce');
    	// All terms:
    	$gender_terms = get_terms('gender', 'hide_empty=0');
    	// All terms currently assigned to the post:
    	$post_terms = wp_get_object_terms($post->ID, 'gender');
    	// All terms currently assigned to the post inside an array:
    	$current_terms = array();
    	if ($post_terms) {
    		foreach ($post_terms as $post_term) {
    			$current_terms[] = $post_term->term_id;
    	// Echo list:
    	foreach ($gender_terms as $term) {
    		if (in_array($term->term_id, $current_terms)) {
    			echo('<li id="gender-'.$term->term_id.'">
    						<input value="'.$term->slug.'" type="checkbox" id="in-gender-'.$term->term_id.'" name="gender-data[]" checked="checked" />'.$term->name.'
    		} else {
    			echo('<li id="gender-'.$term->term_id.'">
    						<input value="'.$term->slug.'" type="checkbox" id="in-gender-'.$term->term_id.'" name="gender-data[]" />'.$term->name.'

    - Saving function (this does NOT work):
    First does some default checks and then tries to save the new settings set by the checkboxes

    function save_meta_gender($post_id, $post, $update) {
    	if (!isset( $_POST['meta_gender_nonce'] ) || !wp_verify_nonce( $_POST['meta_gender_nonce'], basename( __FILE__ ) ) ){
    	if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
    	if (!current_user_can( 'edit_post', $post_id ) ){
    	if (isset($_POST['gender-data'])) {
    		$gender_data = $_POST['gender-data'];
    		wp_set_object_terms($post_id, $gender_data, 'gender' );
    add_action('save_post', 'save_meta_gender', 10, 3);

    0 0

    I'm trying to set up an ajax login for a cordova based app. I am building it into the theme functions.php

    It was working, then has just stopped working. No new plugins or updates that I am aware of to the core.

    So far I have switched from get to post and vice versa. I tried standard jquery ajax call and the xhr method as shown below, but I am having no luck.

    Probably a stupid error, but I am not finding it.

    function login()
    		 	$creds['user_login'] = $_GET["username"];
    			$creds['user_password'] = $_GET["password"];
    			$return = array(); //What we send back
    		if( !empty($_GET["username"]) && !empty($_GET["password"]) && trim($_GET["username"]) != '' && trim($_GET["password"] != '') ){
    			$credentials = array('user_login' => $_GET["username"], 'user_password'=> $_GET["password"], 'remember' => 'true');
    			$loginResult = wp_signon($credentials);
    			$user_role = 'null';
    			if ( strtolower(get_class($loginResult)) == 'wp_user' ) {
    				//User login successful
    				$current_user = $loginResult;
    				/* @var $loginResult WP_User */
    				$return['result'] = true;
    				$creds = array();
    	$auth_resp = "TRUE";
    	$creds_id = $current_user->id;
    	$img_url_temp = $current_user->id;
    	$creds_login = $current_user->user_login;
    	$creds_pass = 'correct';
    	$creds_email = $current_user->user_email;
    	$creds_role = $current_user->user_level;
    	$creds_fname = $current_user->user_firstname;
    	$creds_lname = $current_user->user_lastname;
    	$creds_dispname = $current_user->display_name;
    	$creds_imgurl = get_av_url($creds_id);
    	$creds_coverurl = get_cover_url($creds_id);
    	$creds_array = array($auth_resp,$creds_id,$current_user->user_login,$creds_pass,$creds_email,$creds_role,$creds_fname,$creds_lname,$creds_dispname,$creds_imgurl,$creds_coverurl);
    	array_push($creds, $creds_array);
    	header("Content-Type: application/json");
    	echo json_encode($creds);
    			} elseif ( strtolower(get_class($loginResult)) == 'wp_error' ) {
    				//User login failed
    				/* @var WP_Error $loginResult */
    				$return['result'] = false;
    				echo $loginResult->get_error_message();
    			} else {
    				//Undefined Error
    				$return['result'] = false;
    				echo 'An undefined error has ocurred';
    			$return['result'] = false;
    			echo 'Please supply your username and password.';
    		$return['action'] = 'login';
    		//Return the result array with errors etc.
    		//echo json_decode($return);
    add_action("wp_ajax_login", "login");
    add_action("wp_ajax_nopriv_login", "login");
    var xhr = new XMLHttpRequest();"get", ajaxurl + "?action=login&username=" + encodeURIComponent(usernameF) + "&password=" + encodeURIComponent(passwordF));
        xhr.onload = function(){
    		var creds = [];
    		var user_info_storage = "";
    		var log = "";
    		var id = "";
    		var login_array = JSON.parse(xhr.responseText);
    		var creds_login = "";
    		var creds_pass = "";
    		var creds_email = "";
    		var creds_role = "";
    		var creds_fname = "";
    		var creds_lname = "";
    		var creds_dispname = "";
    		var creds_imgurl = "";
    		var creds_coverurl = "";
    		for(var count = 0; count < login_array.length; count++)
                log = login_array[count][0];
                id = login_array[count][1];
                creds_login = login_array[count][2];
                creds_pass = login_array[count][3];
    			creds_email = login_array[count][4];
    			creds_role = login_array[count][5];
    			creds_fname = login_array[count][6];
    			creds_lname = login_array[count][7];
    			creds_dispname = login_array[count][8];
    			creds_imgurl = login_array[count][9];
    			creds_coverurl = login_array[count][10];
            if(log == "FALSE")
                // alert("Wrong Username and Password", null, "Wrong Creds", "Try Again");
                    title: 'Login Error',
                    subtitle: '',
                    message: 'Wrong login or password',
                    media: '<i class="trekicons trek-trekfind"></i>'
                $('#login_loader').css('display', 'none');
                $('#login_form').fadeTo('fast', 1, function () {
                    // Animation complete.
            else if(log == "TRUE")
    			if(id == 0){
    				//alert("Incorrect feedback");
    				window.setTimeout(login, 1000);
    			} else {
    			    window.localStorage.setItem("", JSON.stringify([creds]));
    			$('#login_loader').css('display', 'none');
    			//$('#login_form').fadeTo('fast', 1, function () {
    			    // Animation complete.

    0 0

    Hi there,

    I need to sort post when displaying with archive page.
    I want post in randomize order except some which are market as "partner". These must be displayed first.

    I don't know how to do that.

    Using custom field or taxonomy ?

    Thanks for your help.

    0 0

    Hey there!

    The WP-dashboard can have up to four columns for boxes, but the "new post"- and "edit post"-page is limited to two columns. Is there any way to increase the number of columns with WP 4.4.x? There are two plugins and some tips, but they didn't work anymore:. :-( Any ideas?

    0 0

    I have this code..

    add_menu_page('CSA Administrator','CSA Administrator','administrator','csa-admin-menu','csa_dashboard_page');

    I am trying to have a Menu structure like this
    CSA Administrator >
    Sub menu item 2
    Sub menu item 3

    However I get an extra item at the top of the submenu list like this..

    CSA Administrator >
    CSA Administrator
    Sub menu item 2
    Sub menu item 3

    I have followed the codex so please help.

    0 0

    Hi, my first post here. Pls blow my mind away.

    I need to customize VC's Single Image element from my plugin.
    I found this:

    add_filter( 'vc_shortcode_set_template_vc_single_image', array(
    ) );


    public function addVcSingleImageShortcodesTemplates( $template ) {
    $file = vc_path_dir( 'TEMPLATES_DIR', 'params/vc_grid_item/shortcodes/vc_single_image.php' );
    if ( is_file( $file ) ) {
    return $file;
    return $template;

    in class-vc-grid-item.php.

    I know for a fact that vc_single_image.php is the file that runs when displaying images on the site, but I can comment out the function addVcSingleImageShortcodesTemplates and it will still run without errors (and images will be displayed). I dont see how remove_filter( 'vc_shortcode_set_template_vc_single_image',...) could help.

    Could anyone explain to me how this works? How can I customize vc_single_image.php (I need to add more html tags to an image) from my plugin?
    Right now I have hard-coded my changes in vc_single_image.php and ofc they will be overwritten when VC updates.

    Unfortunately I cant link to project because problem is in admin panel.

    Any help is appreciated!

    Thank you

    0 0

    Starting with 4.4 WordPress adds a new HTTP Header. It looks like this:

    Link: "<>; rel="""

    Does anyone know how to remove it? I know the REST API can be disabled, but I still would like to remove the HTTP Header as well.

    Also starting with 4.4 old methods to remove the X-Pingback HTTP Header no longer work. This is the header I am talking about:

    X-Pingback: ""

    I would be very happy if anyone could tell me how to remove both of these headers.

    0 0


    i want to add several custom-post-types. i already read through this , several tutorials and so far it works perfectly.

    Now i want to create relations between them.
    Can you hint me to a tutorial or even post a sample where a custom-post type is created with a 1-n relation to another post-type? (parent-child)

    I also will need a sample for m-n relation.

    i searched for a while but didn't find anything, only plugins but i don't know how to use them.

    0 0

    I'm working on an existing website where a previous developer had setup a Service page area on the homepage, using tabbed data, links and page templates. The link is here, the area in question is inside the main header/slider, the 4 tabbed pages that link off to the relevant section.

    The client is looking to change this, and instead of linking to pages setup that use a Service page template, they want to link to individual categories setup instead, such as category for 'Demolition' etc. I'm a junior developer and very much still learning PHP and WordPress. After googling a few queries, not knowing how to word it correctly, I decided to ask on here for advice. I will post the code which outputs the current query.

    <?php $services = get_pages(array(
                  'meta_key' => '_wp_page_template',
                  'meta_value' => 'page-templates/page-service.php'
              )); ?>
              <ul class="custom-tabs">
                <?php foreach ( $services as $service ) {
                  $service_link++; ?>
                  <li class="tab-link<?php if($service_link == 1) { echo ' current'; } ?>" data-tab="tab-<?php echo $service_link; ?>">
                    <i class="icon-<?php echo $service->post_name; ?>"></i>
                <?php } ?>
              <?php foreach ( $services as $service ) {
                $limit = 35;
                $service_content = explode(' ', $service->post_content, $limit);
                if (count($service_content)>=$limit) {
                $service_content = implode(" ",$service_content).'...';
                } else {
                $service_content = implode(" ",$service_content);
                $service_content = preg_replace('<code>\[[^\]]*\]</code>','',$service_content); ?>
                <div id="tab-<?php echo $service_div; ?>" class="tab-content <?php if($service_div == 1) { echo 'current'; } ?>">
                  <p class="title"><?php echo $service->post_title; ?></p>
                  <p class="desc"><?php echo $service_content; ?></p>
                  <a class="service-link" href="<?php echo the_permalink($service->ID); ?>"><?php echo $service->post_title; ?> Services <i class="icon-arrow-right"></i></a>
            <?php } ?>

    Could this be done? Can I amend the get_pages array to get_category array or something along those lines? Appreciate any help or pointers with this. Thanks

    0 0

    Is it possible to write css that will allow me to have different site title tags or maybe logo images on different pages?

    I did find css code to change header image on 1 page by it's page id (xxxx) but I need to make this change for a range of pages that are not sequentially in order.
    .page-id-xxxx #header { background: url("imageurl") no-repeat scroll 0 0 transparent; }
    I'm not familiar with css much so I'm not sure if my need is possible or if I need to use php in the functions.php file.

    I'd also like to really focus more on an element ID that needs to be changed per page.
    <div id="title-to-switch"><h1>My-Title-to-Change</h1></div>

    0 0

    How to physically rename 'wp-admin' ?
    for e.g. wp-admin -> admin .
    not the .htaccess , function.php one

    Thank You !

    0 0

    I am trying to run s cript from a post, when user has clicked the <--more--> tag and is sent to the single post view. The script should not execute when the home page is loaded and 10 or more posts are listed. Only if user clicks <---more---> tag
    Can you make an If(....) {} thing?
    Thnak you for all tips.


    0 0

    How to remove this script in the wp-footer:


    wp_deregister_script( 'wp-embed.min.js' );
    wp_deregister_script( 'wp-embed' );
    wp_deregister_script( 'embed' );

    Do not work -.-

    0 0

    I was wondering if anyone could help me add some code to this plugin, WooCommerce Product Gift Wrap. I really need this plugin to add the extra fee (gift wrapping fee) without it adding it to the price of the product because, if i have a discount on that product and add the gift wrapping to it, it calculates the discount of the gift wrapping fee which it shouldn´t.

    Thank you! :)

    0 0

    Hi Guys,

    I would like to kindly ask you for help with 'set_user_role' action hook. I am trying to code my own function which will send email to user every time the user role is changed. However, the behaviour is quite strange.

    When user has no role set and I assign a new role, email is sent and everything's okay. When user already has some role assigned and I change it to something else, no email is sent. I thought this hook is triggered every single time the role is changed so not sure what's wrong here.

    Also, the hook's parameter $role is always empty while it should contain user's new role. I would like to sent different emails based on the type of role but with this empty variable it's not possible.

    Many thanks for help, hopefully someone had the same experience as me.

older | 1 | .... | 364 | 365 | (Page 366) | 367 | 368 | .... | 413 | newer