• Resolved mihaela02

    (@mihaela02)


    Hello,

    I want to place the content of a page in a colorbox.
    Here is the code:
    `$href = get_permalink(get_option(‘ProjectTheme_set_values_page_id’));
    echo ‘<link media=”screen” rel=”stylesheet” href=”‘.get_bloginfo(‘template_url’).’/css/colorbox.css” />’;
    echo ‘<script src=”‘.get_bloginfo(‘template_url’).’/js/jquery.colorbox.js”> </script>’;
    ?>
    <script src=”//ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/jquery- ui.min.js”></script>
    <script>
    var $ = jQuery;
    $.colorbox.settings.load = true;
    $(document).ready(function(){
    $.colorbox({closeButton:false, overlayClose:false, escKey:false, iframe:true,
    href:”$href”} );
    });
    </script>`
    It appear a small colorbox without any contentt. What is wrong whih this code? Which is the correct value for href in order to display the page?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator bcworkz

    (@bcworkz)

    You may be missing the core jQuery library. It’s highly advisable to use WP’s local version of jQuery and jQuery UI to prevent conflicts. To do so, use wp_enqueue_script(). The libraries are already registered, you just need to enqueue them. The handles are listed here:
    https://developer.www.ads-software.com/reference/functions/wp_enqueue_script/

    Note that the WP version of jQuery runs in noConflict mode, meaning you cannot use the ‘$’ shortcut, use jQuery or construct a noConflict wrapper.

    Thread Starter mihaela02

    (@mihaela02)

    Thank you. Now there is another problem How to display a php file in colorbox?
    I tried to put in href the absolute path of file, but nothing.

    Moderator bcworkz

    (@bcworkz)

    Absolute path as in /home/content/0123456/html/wp-content/plugins/my-plugin/my-plugin.php? Href is expecting an URL as in hxxp://example.com/wp-content/plugins/my-plugin/my-plugin.php
    (with http instead of hxxp of course)

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Add content of a wordpress page in colorbox’ is closed to new replies.