• Resolved bandwagon

    (@bandwagon)


    I am trying to dynamically get my wordpress install directory. For example, if the url of my wordpress installation is https://www.example.com/blog/, I would like to have my script return “/blog/”. I’ve tried bloginfo(‘home’) et al. I’ve also tried this:

    `
    $search = “https://”.$_SERVER[“HTTP_HOST”];
    $replace = “”;
    $mix = bloginfo(‘siteurl’);
    $newphrase = str_replace(“$search”, “$replace”, $mix);
    `

    No dice.

Viewing 1 replies (of 1 total)
  • Thread Starter bandwagon

    (@bandwagon)

    This solved my problem… placed it in functions.php of my current theme:

    `function get_install_dir() {
    $get_url = get_bloginfo(‘url’);
    $split_values = explode(“/”, $get_url);
    echo $split_values[3];
    }`

    To those interested chirping crickets out there, I wanted this in order to customize a multisite installation where several different blogs read from the same theme while calling different versions of images. I can now do this with:

    <img src="<?php bloginfo('template_directory'); ?>/graphics/<?php get_install_dir(); ?>/logo.jpg" alt="FacultyCommons" />

Viewing 1 replies (of 1 total)
  • The topic ‘Return the install directory’ is closed to new replies.