• Resolved vectyr

    (@vectyr)


    I’ve got a custom field named “social”. I would like to use a custom field to kind of pull off a php include maneuver here. So, I thought that maybe I could use “social.php” for the value and then wrap that with the rest of the php include code. So the get_post_meta would grab the custom field value and create the php include. Something like this, but that works.

    <?php echo get_post_meta($post->ID, ‘<?php include(“/images/’,’social’,'”); ?>’, true); ?>

    I know just enough php to be dangerous. But right now, I’m feeling pretty harmless.

Viewing 4 replies - 16 through 19 (of 19 total)
  • Thread Starter vectyr

    (@vectyr)

    I don’t necessarily need that file to be in another folder. I’m fine with doing it the way you advised.

    When you said this:

    <?php
    echo 'this is the include file ';
    ?>

    Where it says ‘this is the include file’ do I put ‘/images/social.php’ or do I put ‘<?php include(“/images/social.php”); ?>’

    Neither work, but I am using 2 social.php files, one in my theme and another in my images folder that has the code in it. Should I not be using the one in my images folder and place my code in the the one in my theme folder? like:

    <?php
    echo 'social.php';
    <!--code goes here-->
    ?>

    Thread Starter vectyr

    (@vectyr)

    I’ve checked, double checked and triple checked and this is what I get: https://joshstevensfoundation.org/dev/about/

    I think my error is in what I pointed out above. I’m trying everything man.

    Thread Starter vectyr

    (@vectyr)

    What if I wanted to use custom fields to display a specific sidebar?

    Thread Starter vectyr

    (@vectyr)

    Figured it out. Holy cow. Ok, so I didn’t have to put the whole: `<?php
    echo ‘social.php’;
    ?>`

    I just cleared everything and stuck the social code in there. Works! Thanks man!

Viewing 4 replies - 16 through 19 (of 19 total)
  • The topic ‘A sneaky custom field php idea’ is closed to new replies.