toggle menu

ACF Filed for taxnomy data not get by function :
get_field("taxnomy_name");

get_field("taxnomy_name",term_id);

get_field("taxnomy_name",post_id);

  • 0 like
  • 1 comment

Dhananjay Kumar23 Jan at 10:01

Get the Answer and the correct answer is.
$object = get_queried_object();
get_field("field_name",$object->taxonomy . '_' . $object->term_id);

Hello,

I have set up wp mail setup plugina and set gmail SMTP and test mail going correctly.

But contact form with sent mail getting below error

"There was an error trying to send your message. Please try again later."

  • 0 like
  • 0 comment

How to get filter by ACF field in wordpress?

Dhananjay Kumar |03 Jun at 01:06

How to get filter by ACF field in wordpress,
i need to show the post data by filtering or searching by used ACF fileds.

  • 0 like
  • 0 comment

How to get post id by slug in wordpress?

Dhananjay Kumar |03 Jun at 08:06

I want to get page id or post all information by SLUG in wordpress.

 

  • 0 like
  • 0 comment

We have created custom post type by function.php and changing URL by category alais before the name by below code

function custom_post_link( $post_link, $id = 0 ){
    $post = get_post($id); 
    if ( is_object( $post )){
        $terms = wp_get_object_terms( $post->ID, 'custom_category' );
        if( $terms ){
            return str_replace( '%custom_category%' , $terms[0]->slug , $post_link );
        }
    }
    return $post_link; 
}
add_filter( 'post_type_link', 'custom_post_link', 1, 3 );

 

after using this script pages redirection error with multiple "301 redirection on page issues".

Suggest, if any have solution about this.

  • 0 like
  • 0 comment

Change URL in wordpress mysql database table

Dhananjay Kumar |22 May at 12:05

I need to change URL in my post content , suggest query to quick replace all.

  • 0 like
  • 1 comment

Dhananjay Kumar23 May at 01:05

getting solution and use this below code:
update `wp_posts` set post_content = replace (post_content,'xyzzzzzz','xyz');

Hello Friends,

I have issues, in wordpress page on AMP i want to all without AMP url convert in to AMP URL.

Any php script or fuction suggest.

Thanks in advance.

 

  • 0 like
  • 0 comment

ACF date fileds behalf of filltering data

Dhananjay Kumar |18 Apr at 01:04

Hello,

I have added start and end date in post type using advance custome fileds.

and want to view post list as per start & end date like  current events, past events and upcoming events..

I have do with below script :

if($_REQUEST['status']=="current"){
                $today = date('Ymd');
                $artposts = get_posts( array(
                'posts_per_page' => 30,
                'post_type'   => 'exhibitions',
                'meta_query' => array('relation' => 'OR',
                                      array('name'=> 'the_beginning_of_the_exhibition',
                                      'value'=> $today,
                                      'type' => 'DATE',
                                      'compare' => '<='),
                                      array('name'=> 'end_of_the_exhibition',
                                      'value'=> $today,
                                      'type' => 'DATE',
                                      'compare'    => '>=')
                                      ),
                'sort_order' => 'desc'
                ) );
               
            }else if($_REQUEST['status']=="past"){
                $artposts = get_posts( array(
                'posts_per_page' => 30,
                'post_type'   => 'exhibitions',
                'meta_query' => array(
                                     
                                      array('name'=> 'end_of_the_exhibition',
                                      'value'=> date('Ymd'),
                                      'type' => 'DATE',
                                      'compare'    => '<')
                                      ),
                'sort_order' => 'desc'
                ) );
               
            }else if($_REQUEST['status']=="upcoming"){
                $artposts = get_posts( array(
                'posts_per_page' => 30,
                'post_type'   => 'exhibitions',
                'meta_query' => array(
                                     
                                      array('name'=> 'the_beginning_of_the_exhibition',
                                      'value'=> date('Ymd'),
                                      'type' => 'DATE',
                                      'compare'    => '>')
                                      ),
                'sort_order' => 'desc'
                ) );
               
            }

 

Getting proper result with past and upcoming, but issues seems with current, any one have solution please suggest.

  • 2 likes
  • 0 comment

Hello,

 

I have problem with ACF repeter, not able to retrive value in front end with below script :
if( have_rows('Location_repeter') ):

    while ( have_rows('Location_repeter') ) : the_row();


        the_sub_field('location_name');

    endwhile;
endif;

 

Is any solution for thats?

 

  • 0 like
  • 0 comment

Remove defualt canonical from head in wordpress

Dhananjay Kumar |03 Oct at 12:10

Use the below script:

remove_action('wp_head', 'rel_canonical');  

 

  • 1 like
  • 0 comment

Get the Page Template all pages in wordpress

Dhananjay Kumar |03 Oct at 10:10

Hi All,

I have sloved the problem with below script:

           $args = array(
                'post_type' => 'page',
                'posts_per_page' => -1,
                'meta_query' => array(
                    array(
                        'key' => '_wp_page_template',
                        'value' => 'page-template.php'
                    )
                )
            );
            $the_pages = new WP_Query( $args );
            $arraypage=array();
            $arraypagestitle=array();
            if( $the_pages->have_posts() ){
                while( $the_pages->have_posts() ){
                    $the_pages->the_post();
                    $arraypage[]=array("slug"=>get_permalink(), "title"=>get_the_title());
                }
            }
            wp_reset_postdata(); 

  • 1 like
  • 0 comment

Custom search script in woocommerce product with ACF

Dhananjay Kumar |26 Jul at 11:07

I want to create a custom search for a woocommerce product with woocommerce fields and advanced custom fields.

Like price range of woocommerce fields and other fields type using advance custom fields (ACF).

  • 1 like
  • 1 comment

Dhananjay Kumar26 Jul at 12:07

I got the solution, with below script:

We have work on product-arcive.php

------------------------------------------------------------------------------------------------------
$args['post_type'] = 'product';
$taxquery=array();
if(count($_REQUEST)>0){
foreach($_REQUEST as $key=>$val){
if($key=="min_price" && $val!=""){
$passarg[]=array('key'=> '_price',
'value' => $val,
'compare' => '>=',
'type' => 'NUMERIC'
);
}
if($key=="max_price" && $val!=""){
$passarg[]=array('key'=> '_price',
'value' => $val,
'compare' => '<=',
'type' => 'NUMERIC'
);
}
if($key=="acf_field"){

$passarg[]=array('key'=> $key,
'value' => $val,
'compare' => '=',
);


}
}
}

$args['meta_query'] = $passarg;
query_posts( $args );
$the_query = new WP_Query( $args );
------------------------------------------------------------------------------------------------------

My project's requirement is to integrate codeigniter and wordpress. Codeigniter files are in root directory of wordpress. Everything is working fine in wordpress but when i access the codeigniter pages it redirect me on wordpress's page not found page. My site is running on LEMP server. i searched regarding it on google , there were some solutions so i tried them but nothing worked in my case. Please help. I thank you in advance.

  • 1 like
  • 1 comment

Dhananjay Kumar26 May at 11:05

I was getting the same issues with LEMP server cause there, not .htaccess file working.
Due to this reason Codeigniter files path "https://abc.com/xyz/" is followed WordPress URL.
I have done the following below script in /etc/nginx/sites-enabled/default file:

location /xyz {
try_files $uri $uri/ /xyz/index.php?$args;
}
location /test {
try_files $uri $uri/ /test/index.php?$args;
}

Added above multiple "location" path which using in CodeIgniter. And its working fine for me.
Please once try above, hope you getting the solution.

I have implement in wordpress search for the prodcut taxonomy & meta fileds (for extra fileds by advance custome fileds).

Please review below my script.

<?php
$args['post_type'] = 'product';
$args['tax_query'] = array(array(
                                'taxonomy'  => 'product_tag',
                                'field'     => 'slug',
                                'terms'     => slug_name'',
                                ));   
$args['meta_query'] = array(array('key'=> $key,
                                  'value'          => $val,
                                  'compare'     => '=',
                            ));
query_posts( $args );

?>

 

  • 1 like
  • 0 comment

Select dropdown list of taxonomy in wordpress

Dhananjay Kumar |28 Apr at 07:04

Hello,
I have simple need to show a dropdown list of all taxonomy (for tag & category) of prodcut post type of woocommerce.
We have used below script & ite working fine for me.
<?php
$terms_result = get_terms("taxonomy_name");
$slected='';
    echo '<select name="fld_name">';
        echo '<option value="">Select Option</option>';
        foreach( $terms_result as $k => $v )
        {
            $vslag=$v->slug;
            $vname=$v->name;
         
            echo '<option value="' . $vslag . '"  >' . $vname. '</option>';
        }
    echo '</select>';

?>

  • 1 like
  • 0 comment

Issues with the meta canonical path after cahnge with custome path, seems original path rether than as Per New URL.
We have done with below works :
$pathqery=explode('?',$_SERVER['REQUEST_URI']);
?>

remove_action('wp_head', 'rel_canonical');
wp_head();
....

....

  • 4 likes
  • 1 comment

Dhanavi29 Mar at 06:03

Thanks, it's working fine

Hey guys!

I have had problem with worpress image attachment URL which is creating problem for tech SEO, I found the solution for it how to redirect image URL to attachment page with 301 redirection.

You need to put below following code in FUNCTION.PHP inside you theme file

add_action( 'template_redirect', 'wpse27119_template_redirect' );
function wpse27119_template_redirect()
{
// Get out of here if not headed to an attachment page	
if( ! is_attachment() ) return;	

// Find the $post variable representing the page where we're heading
global $post;
if( empty( $post ) ) $post = get_queried_object();	

// Check if post has a parent	
if ($post->post_parent)
	{
	// Yes so find permalink of parent post
	$link = get_permalink( $post->post_parent );
	// Redirect attachment to the parent post
	wp_redirect( $link, '301' );
	exit(); // always call exit after wp_redirect
	}
else	
	{
	// No parent so just redirect to home page
	wp_redirect( home_url(), '301' );
	exit(); // always call exit after wp_redirect
	}
}

 

  • 2 likes
  • 0 comment

I have set value in header.php in worpdress and calling the same veriable but not getting value.

Like set $x="abc" in header.php &

echo $x in footer.php

getting blank value, please any one suggest

  • 0 like
  • 0 comment

I want to call codeigniter developed function inside the WordPress template page, suggest me about this its possible or not? 

  • 0 like
  • 0 comment

How to get fields value of post_type taxonomy terms?

Dhananjay Kumar |22 Mar at 06:03

In Wp-admin we have created a post_type and taxonomy. In taxonomy added lots of terms data with additional fields. We want to show that fields value in front end behalf of a slug.

  • 2 likes
  • 1 comment

Sanjana Kumari22 Mar at 06:03

Please use this below code, its help you
//$current_id = get_the_ID();
$uri=explode("/",$_SERVER['REQUEST_URI']);
//print_r($uri);
$slug=$uri[2]; // slug getting from address of URL
$taxonomy_names = get_term_by('slug',$slug,'taxonomy_name_pass');
// print_r( $taxonomy_names );
echo $taxonomy_names->term_id
echo $taxonomy_names->name
echo $taxonomy_names->description
// for use with advance or custome fields below query
$term_meta = get_term_meta( $taxonomy_names->term_id );
echo $term_meta[fileds_name][0];
?>