Category Archives: Website developer

Website developer Wordpress

All 404 redirect by .htaccess and PHP

Published by:

All 404 redirect by .htaccess and PHP

1- Edit or create the file ..htaccess:

ErrorDocument 404 /404.php

 

2- Create the file php 404.php

<?php
//on .htacessErrorDocument 404 /404.php
header(‘location:https://www.ukgoodbye.co.uk/shop’);
?>

Example:

https://ukgoodbye.co.uk/shop/thisfileNOtExisit

 

 

Website developer Wordpress

carouFredSel, FadeIn effect

Published by:

carouFredSel, FadeIn effect

scroll { fx : “scroll” }
Indicates which effect to use for the transition.
Possible values: “none”, “scroll”, “directscroll”, “fade”, “crossfade”, “cover”, “cover-fade”, “uncover” or “uncover-fade”.

Example:

jQuery(document).ready(function($){
$(‘#divtestimonials’).carouFredSel({
responsive: true,
width: ‘100%’,
scroll: 1,
auto:4000,
scroll: {
fx:’fade’,
items: 1,
duration: 1000

},
items: {
width: lalargeur,
height: 250, // optionally resize item-height
visible: {
min: 1,
max: 1

}

}
});

Website developer Wordpress

Make Fancybox appear on top of the page

Published by:

Make Fancybox appear on top of the page
When setup a link to an image using fancybox but when the user clicks on the thumbnail the fancybox box won’t appears on the top all your content. Like you can see on the next image:


An easy and quick solution for that is setup the z-index of fancybox container

.fancybox-container{
z-index:9999999999!important;
}

Now us result that your image should appear on the top of everything:
FancyBox on the top of everything

Website developer Wordpress

Solution for this, The hook name can only contain numbers, letters, dashes, periods and underscores, WP 5.0.2 and ACF

Published by:

Solution for this, The hook name can only contain numbers, letters, dashes, periods and underscores.
Environment:
Wordpress:5.0.2

Error message:
…The hook name can only contain numbers, letters, dashes, periods and underscores. hooks.min.js:1:1495
o
http://localhost:8888/esse/wp-includes/js/dist/hooks.min.js:1:1495
i/<
http://localhost:8888/esse/wp-includes/js/dist/hooks.min.js:1:1707
add_action
http://localhost:8888/esse/wp-content/plugins/advanced-custom-fields-pro/assets/js/acf-input.min.js:1:1933

http://localhost:8888/esse/wp-content/plugins/acf-enhanced-message-field/js/input.js:19:2

http://localhost:8888/esse/wp-content/plugins/acf-enhanced-message-field/js/input.js:1:2
..

Resulting the ACF repeater won’ t save the content. Any solution?

1- After a long time investigating it looks like ACF(Avanced Custom Field), or/and ACF Repeater & Flexible Content Collapser is not working on the WordPress Version 5.0.2.
The urgent and quick solution for me was going back the previous version of WordPress.
WP version 5.0.2 and ACF

Website developer Wordpress

Exclude category WordPress ,WP_Query category__not_in or cat -cat_ID not working

Published by:

Exclude category WordPress ,WP_Query category__not_in or cat -cat_ID not working

Here is the example:

$recent_posts_query_args = array(
‘posts_per_page’ => 5,
‘post_status’ => ‘publish’,
‘order’ => ‘DESC’,
‘post_type’ => ‘product’,
‘category__not_in’=>array(43)
$recent_posts = new WP_Query( $recent_posts_query_args );

It suppose to not include the articles where the category has code 43, but is not working.

The reason is not working is because, the category 43 is not WP category code is tag code 43 for post type “product”, so to do so you will need filter using tax_query

$recent_posts_query_args = array(
‘posts_per_page’ => 5,
‘post_status’ => ‘publish’,
‘order’ => ‘DESC’,
‘post_type’ => ‘product’,
‘tax_query’=>array(array(
‘taxonomy’ => ‘product_cat’,
‘terms’ => 43,
‘field’ => ‘id’,
‘operator’ => ‘NOT IN’,
))

);
$recent_posts = new WP_Query($recent_posts_query_args );

Website developer Wordpress

Fixed size of Flexslider, controlling the height

Published by:

1- Incliude the stylesheet abd jquery and flexslider-min


var $f = jQuery.noConflict(true);
$f(window).load(function() {
// The slider being synced must be initialized first
$f(‘#carousel’).flexslider({
animation: “slide”,
controlNav: false,
animationLoop: false,
slideshow: false,
itemWidth: 75,
itemMargin: 5,
asNavFor: ‘#slider’
});

$f(‘#slider’).flexslider({
animation: “slide”,
controlNav: false,
animationLoop: false,
slideshow: false,
sync: “#carousel”
});
});

2. … and now you will to control the height of the images… by add the next style rules..

.flexslider .slides img {
max-height: 600px; /*maximum height for all slides*/
width: auto; /*proper aspect ratio of images*/
max-width: 100%; /*maximum width for all slides*/
margin: 0 auto; /*centering images in the container*/
}
Website developer Wordpress

WP, how to add your custom post type by code

Published by:

WP, how to add your custom post type by code

“WordPress can hold and display many different types of content. A single item of such a content is generally called a post, although post is also a specific post type. The table of that contains the posts is “wp_posts” the database that is normally MySQL.”
The default posts types on WordPress are:

  1. Post (Post Type: ‘post’)
  2. Page (Post Type: ‘page’)
  3. Attachment (Post Type: ‘attachment’)
  4. Revision (Post Type: ‘revision’)
  5. Navigation Menu (Post Type: ‘nav_menu_item’)
  6. Custom CSS (Post Type: ‘custom_css’)
  7. Changesets (Post Type: ‘customize_changeset’)
  8. User Data Request (Post Type: ‘user_request’ )
  9. Custom Post Types

The custom Post Types are the new post types. We are going to create a post types “Testimonials”, to do so we will to add
a custom post type to WordPress via the register_post_type() function and this allows us to define a new post type by its labels, supported features, availability and other specifics.

Note that you must call register_post_type() before the admin_menu and after the after_setup_theme action hooks. A good hook to use is the init hook.

1- Create the post type function

function create_post_type() {
  register_post_type( 'esm_testimonials',
    array(
      'labels' => array(
        'name' => __( 'Testimonials' ),
        'singular_name' => __( 'Testimonial' )
      ),
      'public' => true,
      'has_archive' => true,
    )
  );
}
add_action( 'init', 'create_post_type' );
2- Add the above function to your WP
Navigate to WordPress(WP), rootDirectory/wp-content/themes/your-theme/functions.php
wp custom post type

 

3- Check for our Custom post type, on WP admin

We should see on WordPress, www.ourhost.com/wp-admin, our custom post type added. “Testimonials”

4- Optional, add existing category to a Custom post type
The custom post type is created successfully, we want to add an existing category called “Testimonial” our brand new custom type.
// I- Add existing taxonomies to post type testimonials
add_action( ‘init’, ‘wp_add_taxonomies_to_testimonials’ );
function wp_add_taxonomies_to_testimonials() {
register_taxonomy_for_object_type( ‘category’, ‘testimonial’ );
register_taxonomy_for_object_type( ‘post_tag’, ‘testimonial’ );
}

// II. Make Testimonial posts show up in archive pages
add_filter( ‘pre_get_posts’, ‘wptestimonial_add_custom_post_types_to_query’ );
function wptestimonial_add_custom_post_types_to_query( $query ) {
if(
is_archive() &&
$query->is_main_query() &&
empty( $query->query_vars[‘suppress_filters’] )
) {
$query->set( ‘post_type’, array(
‘post’,
‘testimonial’
) );
}
}

Website developer Wordpress

Custom Field Not showing in wp-admin, access by using the ACF url

Published by:

Custom Field Not showing in wp-admin, access by using the ACF url

ACF, is Advanced Custom Fields for WordPress Developers.
ACF e-smartsolution

If ACF disappeared from ‘New posts’ in the ‘Admin’ back-end, the quick to access directly is by the its URL, your-website.com/wp-admin/edit.php?post_type=acf-field-group

Website developer Wordpress

How to reset password in WordPress via phpMyadmin

Published by:

How to reset password in WordPress via phpMyadmin

You can recover password in WordPress by e-mail. Now click on Lost your password? Type your username or email address and then click on Get New Password.
In the case if you also forgot your email, basically you don’t no information, us last resource to recover your user and password is by accessing the database.

1- Go to PHPMyAdmin.

You will need to access your PHPMyadmin con control panel, and go Now select table prefix_users, usually wp_users

2- Once on phpMyadmin, you can find out your email linked to your account.

You can go back the login page on wordpress to recover your password using this email linked to the username.

3- Reset the password directly on the database, mysql.

You prefer to reset the password directly on the database, to do so, you will need to encrypt your password using the MD5 encryption that is used by WordPress.

Click on the https://e-smartsolution.co.uk/encrypt/ and enter your password en click encrypt. Copy the encrypt password en paste on column that says, “users_pass” on phpMyadmin.