[resolved] Adding shortcode each time php loops (3 posts)

  1. DA2206
    Posted 4 years ago #


    I am currently trying to display a shortcode box each time a php loop runs. This box will contain various images and text selected by the query.

    Extremely new to WP and looking for some advice.

    Current code:

    $imageQuery = "SELECT * FROM X WHERE City LIKE 'City' ORDER BY CityCode";
    $result = mysql_query($imageQuery) or die(mysql_error());
    while( $row=mysql_fetch_row($result) )
    echo do_shortcode[styledbox type="general shaded"  ].$row[1].[/styledbox];

    Essentially a query that i am looking to create a new box each time it runs, with field information displayed relating to the row the loop is on, forming a list of boxes.

    Any help much appreciated,

    Many thanks

  2. Michael
    Forum Moderator
    Posted 4 years ago #

    please check the syntax of do_shortcode()


    for example, try:

    echo do_shortcode('[styledbox type="general shaded"  ]'.$row[1].'[/styledbox]');
  3. DA2206
    Posted 4 years ago #

    Works perfectly, thank you for your help.

Topic Closed

This topic has been closed to new replies.

About this Topic