Support

Account

Home Forums General Issues Loop Post depending on the textfield

Helping

Loop Post depending on the textfield

  • Hello I wanna ask if it’s possible to query post or custom post type depending on the text field value?

    for example i have a Page template called “Loop Posts Template” that I want it dynamically loop the posts but In the page editor I have a blank text field that if I enter the category or taxonomy name, what’s going to show in the template is the loop of the category or taxonomy that I entered.. please help me.

  • Hi @slash_1968

    This is possible both with this plugin and default wordpress theme customizer

    You should add following codes before the loop. The 1st example is for theme customizer and the 2nd is for this plugin.

    <?php 
       $category_slug = get_theme_mod( 'your_field_id' );
       query_posts( array ( 'category_name' => $category_slug ) ); 
    ?>

    ———

    <?php 
       $category_slug = get_field( 'your_field_id' );
       query_posts( array ( 'category_name' => $category_slug ) ); 
    ?>
Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Loop Post depending on the textfield’ is closed to new replies.