How to write a wordpress query when there are multiple values in custom fieldOrder wordpress post by custom field value?Wordpress custom field searchWordpress query - Order by meta-field valuewordpress query post by a custom field that is post typeWordPress WP_Query: Display custom post type based on custom meta value, and also order on another custom meta valueHow to modify custom fields meta box in WordPressUpdating a Wordpress post not working with add_post_metatrying to retrive a post_type with custom fields and media queryRetrieve posts by custom field with WP-REST-API in JavascriptOptimising WordPress query speed by grouping metadata

Robbers: The Hidden OEIS Substring

Redefining hyperref in document referencing

As the Dungeon Master, how do I handle a player that insists on a specific class when I already know that choice will cause issues?

Won 50K! Now what should I do with it

Spectrum vs eigenvalues

Would letting a multiclass character rebuild their character to be single-classed be game-breaking?

Assistant professor does not collaborate with or cite fellow department members, despite them being experts on the topic

Back to the nineties!

How might the United Kingdom become a republic?

What is temperature on a quantum level?

Is this floating-point optimization allowed?

Too many spies!

How does one stock fund's charge of 1% more in operating expenses than another fund lower expected returns by 10%?

As a DM, how to avoid unconscious metagaming when dealing with a high AC character?

The monorail explodes before I can get on it

Can I play a first turn Simic Growth Chamber to have 3 mana available in the second turn?

Why would guns not work in the dungeon?

Was the Ford Model T black because of the speed black paint dries?

Cops: The Hidden OEIS Substring

What does `[$'rn']` mean?

How to check the quality of an audio sample?

Ambiguous sentences: How to tell when they need fixing?

Redirecting of hostname to full qualified domain name with HTTPS fails

Why is dry soil hydrophobic? Bad gardener paradox



How to write a wordpress query when there are multiple values in custom field


Order wordpress post by custom field value?Wordpress custom field searchWordpress query - Order by meta-field valuewordpress query post by a custom field that is post typeWordPress WP_Query: Display custom post type based on custom meta value, and also order on another custom meta valueHow to modify custom fields meta box in WordPressUpdating a Wordpress post not working with add_post_metatrying to retrive a post_type with custom fields and media queryRetrieve posts by custom field with WP-REST-API in JavascriptOptimising WordPress query speed by grouping metadata






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I have a wordpress custom post type with custom fields. Initially the requirement was every post has only one pin "Say example" 1001 and all posts with custom fields has 1001 needs to be retrieved. I used query args as



<?php
$args = array(
'post_type'=> array('sales'),
'posts_per_page' => -1,
'meta_key'=> 'pin',
'meta_value'=> $pin
);
query_posts( $args );
?>


Now I can have multiple zips in single custom field.



https://www.dropbox.com/s/pk53z23jbfj8p2t/zipcode.png?dl=0



How the query needs to be altered so if the entered zip matched any one of the item on the filed, post is displayed.



So for example the custom field has values 63001,63002,63003 and so on. So if user enters 63002 all the posts with 63002 in the custom field needs to be displayed.










share|improve this question






















  • If you have code then please share for better understanding.

    – Dhruv
    Mar 26 at 5:34

















0















I have a wordpress custom post type with custom fields. Initially the requirement was every post has only one pin "Say example" 1001 and all posts with custom fields has 1001 needs to be retrieved. I used query args as



<?php
$args = array(
'post_type'=> array('sales'),
'posts_per_page' => -1,
'meta_key'=> 'pin',
'meta_value'=> $pin
);
query_posts( $args );
?>


Now I can have multiple zips in single custom field.



https://www.dropbox.com/s/pk53z23jbfj8p2t/zipcode.png?dl=0



How the query needs to be altered so if the entered zip matched any one of the item on the filed, post is displayed.



So for example the custom field has values 63001,63002,63003 and so on. So if user enters 63002 all the posts with 63002 in the custom field needs to be displayed.










share|improve this question






















  • If you have code then please share for better understanding.

    – Dhruv
    Mar 26 at 5:34













0












0








0








I have a wordpress custom post type with custom fields. Initially the requirement was every post has only one pin "Say example" 1001 and all posts with custom fields has 1001 needs to be retrieved. I used query args as



<?php
$args = array(
'post_type'=> array('sales'),
'posts_per_page' => -1,
'meta_key'=> 'pin',
'meta_value'=> $pin
);
query_posts( $args );
?>


Now I can have multiple zips in single custom field.



https://www.dropbox.com/s/pk53z23jbfj8p2t/zipcode.png?dl=0



How the query needs to be altered so if the entered zip matched any one of the item on the filed, post is displayed.



So for example the custom field has values 63001,63002,63003 and so on. So if user enters 63002 all the posts with 63002 in the custom field needs to be displayed.










share|improve this question














I have a wordpress custom post type with custom fields. Initially the requirement was every post has only one pin "Say example" 1001 and all posts with custom fields has 1001 needs to be retrieved. I used query args as



<?php
$args = array(
'post_type'=> array('sales'),
'posts_per_page' => -1,
'meta_key'=> 'pin',
'meta_value'=> $pin
);
query_posts( $args );
?>


Now I can have multiple zips in single custom field.



https://www.dropbox.com/s/pk53z23jbfj8p2t/zipcode.png?dl=0



How the query needs to be altered so if the entered zip matched any one of the item on the filed, post is displayed.



So for example the custom field has values 63001,63002,63003 and so on. So if user enters 63002 all the posts with 63002 in the custom field needs to be displayed.







wordpress advanced-custom-fields






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 26 at 5:27









RamRam

631 silver badge11 bronze badges




631 silver badge11 bronze badges












  • If you have code then please share for better understanding.

    – Dhruv
    Mar 26 at 5:34

















  • If you have code then please share for better understanding.

    – Dhruv
    Mar 26 at 5:34
















If you have code then please share for better understanding.

– Dhruv
Mar 26 at 5:34





If you have code then please share for better understanding.

– Dhruv
Mar 26 at 5:34












2 Answers
2






active

oldest

votes


















0














Try below:



 $args = array(
'post_type'=> array('sales'),
'posts_per_page' => -1,
'meta_query' => array( array(
'key'=> 'pin',
'value'=> ','.$pin.',',
'compare'=> 'LIKE'
) )
);
query_posts( $args );





share|improve this answer























  • hi @jayadip its working but returning only 1 result even there are multiple posts. I am debugging it. Do you have any idea of what the issue is. Thanks buddy for your help.

    – Ram
    Mar 26 at 7:50











  • It worked using 'value'=> '$pin'

    – Ram
    Mar 26 at 10:49



















0














try update your post meta value in json type by json_encode and get that by json_decode






share|improve this answer

























    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55350376%2fhow-to-write-a-wordpress-query-when-there-are-multiple-values-in-custom-field%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    Try below:



     $args = array(
    'post_type'=> array('sales'),
    'posts_per_page' => -1,
    'meta_query' => array( array(
    'key'=> 'pin',
    'value'=> ','.$pin.',',
    'compare'=> 'LIKE'
    ) )
    );
    query_posts( $args );





    share|improve this answer























    • hi @jayadip its working but returning only 1 result even there are multiple posts. I am debugging it. Do you have any idea of what the issue is. Thanks buddy for your help.

      – Ram
      Mar 26 at 7:50











    • It worked using 'value'=> '$pin'

      – Ram
      Mar 26 at 10:49
















    0














    Try below:



     $args = array(
    'post_type'=> array('sales'),
    'posts_per_page' => -1,
    'meta_query' => array( array(
    'key'=> 'pin',
    'value'=> ','.$pin.',',
    'compare'=> 'LIKE'
    ) )
    );
    query_posts( $args );





    share|improve this answer























    • hi @jayadip its working but returning only 1 result even there are multiple posts. I am debugging it. Do you have any idea of what the issue is. Thanks buddy for your help.

      – Ram
      Mar 26 at 7:50











    • It worked using 'value'=> '$pin'

      – Ram
      Mar 26 at 10:49














    0












    0








    0







    Try below:



     $args = array(
    'post_type'=> array('sales'),
    'posts_per_page' => -1,
    'meta_query' => array( array(
    'key'=> 'pin',
    'value'=> ','.$pin.',',
    'compare'=> 'LIKE'
    ) )
    );
    query_posts( $args );





    share|improve this answer













    Try below:



     $args = array(
    'post_type'=> array('sales'),
    'posts_per_page' => -1,
    'meta_query' => array( array(
    'key'=> 'pin',
    'value'=> ','.$pin.',',
    'compare'=> 'LIKE'
    ) )
    );
    query_posts( $args );






    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Mar 26 at 7:27









    Jaydip NimavatJaydip Nimavat

    3454 silver badges18 bronze badges




    3454 silver badges18 bronze badges












    • hi @jayadip its working but returning only 1 result even there are multiple posts. I am debugging it. Do you have any idea of what the issue is. Thanks buddy for your help.

      – Ram
      Mar 26 at 7:50











    • It worked using 'value'=> '$pin'

      – Ram
      Mar 26 at 10:49


















    • hi @jayadip its working but returning only 1 result even there are multiple posts. I am debugging it. Do you have any idea of what the issue is. Thanks buddy for your help.

      – Ram
      Mar 26 at 7:50











    • It worked using 'value'=> '$pin'

      – Ram
      Mar 26 at 10:49

















    hi @jayadip its working but returning only 1 result even there are multiple posts. I am debugging it. Do you have any idea of what the issue is. Thanks buddy for your help.

    – Ram
    Mar 26 at 7:50





    hi @jayadip its working but returning only 1 result even there are multiple posts. I am debugging it. Do you have any idea of what the issue is. Thanks buddy for your help.

    – Ram
    Mar 26 at 7:50













    It worked using 'value'=> '$pin'

    – Ram
    Mar 26 at 10:49






    It worked using 'value'=> '$pin'

    – Ram
    Mar 26 at 10:49














    0














    try update your post meta value in json type by json_encode and get that by json_decode






    share|improve this answer



























      0














      try update your post meta value in json type by json_encode and get that by json_decode






      share|improve this answer

























        0












        0








        0







        try update your post meta value in json type by json_encode and get that by json_decode






        share|improve this answer













        try update your post meta value in json type by json_encode and get that by json_decode







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 26 at 7:20









        Iris NguyenIris Nguyen

        84 bronze badges




        84 bronze badges



























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55350376%2fhow-to-write-a-wordpress-query-when-there-are-multiple-values-in-custom-field%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

            용인 삼성생명 블루밍스 목차 통계 역대 감독 선수단 응원단 경기장 같이 보기 외부 링크 둘러보기 메뉴samsungblueminx.comeh선수 명단용인 삼성생명 블루밍스용인 삼성생명 블루밍스ehsamsungblueminx.comeheheheh

            155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해