• Hello,

    I have 20 pages in my site that will have a section with promotions. This section will be the same for all the 20 pages. This promotions will change every month. This promotion section is NOT a sidebar widget.

    I do not want to change manually the 20 pages every month and I am looking for a way to change only one and the change will apply to all the 20 pages automatically.

    If there a way to do this with WP?

    The only solution I could find so far is to create the promotions in a separate HTML file and embed it in the pages with <iframe>

    Does anybody know a better way to acomplish this?

    Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Don’t know if it is better, but you could use a shortcode to pull in the content of a page with the promotion info.

    Thread Starter mako2

    (@mako2)

    Thank you! I didn’t know I could use a shortcode for that. Can you show me an example of how I can use the shortcode to pull in the content?

    The function below will retrieve the content of the first post in a given category.

    // Demonstrate a shortcode for getting content of first post in a category
    // Format: [mam_cat_post cat=32]
    function mam_get_category_post($atts) {
       extract(shortcode_atts(array('cat' => 0), $atts));
       $content = '';
       $cat_query = new WP_Query("cat=$cat&caller_get_posts=1&posts_per_page=1");
       if ($cat_query->have_posts()) {
          while ($cat_query->have_posts()) {
             $cat_query->the_post();
             $content = apply_filters('the_content',get_the_content());
          }
       }
       return $content;
    }
    add_shortcode('mam_cat_post','mam_get_category_post');
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Embeding content into a page’ is closed to new replies.