• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

Placing content above the code in .php

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Archived Forums › Design Tips and Tricks › Placing content above the code in .php

This topic is: not resolved
  • This topic has 19 replies, 3 voices, and was last updated 11 years, 11 months ago by rfmeier.
Viewing 20 posts - 1 through 20 (of 20 total)
  • Author
    Posts
  • June 6, 2013 at 7:21 am #44291
    ᴅᴀᴠɪᴅ
    Member

    Hi, i am wanting to place some simple html, just text and an image at the top of my portfolio page in the website created with the Epik Theme. As the portfolio page is created with page_portfolio.php I am not sure where I can add content to make it appear below the title but above the actual portfolio of images that it produces..

    http://nomadspirit.net/digital-nomad-hotspots/

    I have tried to do research on how to add html to php and learned that you must echo etc but wherever I put this the text always appears above the header. I am obviously missing something but I am not sure how to find out what. Sorry, i usually try my hardest to find the answer myself as that is how I learn quicker than asking but on this one I am stumped.


    I love helping creative entrepreneurs build epic things with WP & Genesis.

    Follow on Twitter

    June 6, 2013 at 7:30 am #44293
    ᴅᴀᴠɪᴅ
    Member

    Sorry i have realised I am asking the wrong question. I am wanting to know how to change the page_portfolio.php so it shows the content of the page before actually creating the portfolio. The only thing it is taking from the actual page that I create in wordpress is the title. Then it goes off and creates a portfolio of images.

    I am guessing it would be something to do with 'entry-content'


    I love helping creative entrepreneurs build epic things with WP & Genesis.

    Follow on Twitter

    June 6, 2013 at 7:35 am #44294
    rfmeier
    Member

    Hello,

    Since I don't have the Epik theme, I am unable to see the source for the page_portfololio.php file, but I will take a stab at it.

    Within the page_portfolio.php page, try pasting this code before the genesis() function;

    /* functions.php */
    add_action( 'genesis_before_post_content', 'my_custom_html' );
    /**
     * Callback for Genesis 'genesis_before_post_content' action.
     * 
     * Print custom html before the post content.
     * 
     * @package Genesis
     * @category Post content
     * @author Ryan Meier http://www.rfmeier.net
     * 
     */
    function my_custom_html(){
    	
    	// print your html here
    	echo '<p>This is a test.</p>';
    	
    }

    If you want your html within the .entry-content element, try using the following instead;

    /* functions.php */
    add_action( 'genesis_post_content', 'my_custom_html', 9 );

    Let me know how this turns out. It may be a matter of finding the correct action to use to place your code in the correct spot.


    Ryan Meier – Twitter

    June 6, 2013 at 8:00 am #44304
    ᴅᴀᴠɪᴅ
    Member

    Hi, thanks for your help. Unfortunately it isn't putting the text where i wanted it though. It is putting it below the title of each of the images contained in the portfolio, not below the title in the actual page itself.

    In the page_portfolio.php there is

    // Adds Page Title and Content
    add_action( 'genesis_before_content', 'genesis_do_post_title' );
    add_action( 'genesis_before_content', 'genesis_do_post_content' );

    At the top, i would have thought this should pull up the title and the content of the page, and then pull the information from the other posts which make up the portfolio page. I have written content in the page but it never displays. I would ask Wes who designed Epik theme but every time I go to his website it never loads. I will keep looking anyway. Thanks for replying so quick btw.


    I love helping creative entrepreneurs build epic things with WP & Genesis.

    Follow on Twitter

    June 6, 2013 at 8:01 am #44306
    rfmeier
    Member

    Gah-- I am sorry. I still need my coffee.

    Let me look at the source again and I will post another update.


    Ryan Meier – Twitter

    June 6, 2013 at 8:02 am #44307
    rfmeier
    Member

    Is there a chance you can paste the page_portfolio.php code? That would alleviate some of the guess work on my side.


    Ryan Meier – Twitter

    June 6, 2013 at 8:05 am #44308
    ᴅᴀᴠɪᴅ
    Member

    <?php

    // Template Name: Portfolio

    // Adds Page Title and Content
    add_action( 'genesis_before_content', 'genesis_do_post_title' );
    add_action( 'genesis_before_content', 'genesis_do_post_content' );

    // Loads prettyPhoto scripts
    add_action( 'get_header', 'prettyPhoto_scripts' );
    function prettyPhoto_scripts() {
    wp_enqueue_script( 'prettyPhoto-min', CHILD_URL.'/lib/prettyPhoto/js/jquery-1.6.1.min.js' );
    wp_enqueue_style( 'prettyPhoto-css', CHILD_URL.'/lib/prettyPhoto/css/prettyPhoto.css' );
    wp_enqueue_script( 'prettyPhoto-js', CHILD_URL.'/lib/prettyPhoto/js/jquery.prettyPhoto.js' );
    }

    // Adds javascript below footer
    add_action( 'genesis_after_footer', 'prettyPhoto_javascript' );
    function prettyPhoto_javascript() { ?>
    <script type="text/javascript" charset="utf-8">
    $(document).ready(function(){
    $("a[rel^='prettyPhoto']").prettyPhoto();
    });
    </script>
    <?php
    }

    // Force layout to full-width-content
    add_filter( 'genesis_site_layout', '__genesis_return_full_width_content' );

    // Adds "portfolio" and "gallery clearfix" classes to every post
    add_filter( 'post_class', 'portfolio_post_class' );
    function portfolio_post_class( $classes ) {
    $classes[] = 'portfolio';
    $classes[] = 'gallery clearfix';
    return $classes;
    }

    add_filter( 'excerpt_more', 'portfolio_read_more_link' );
    add_filter( 'get_the_content_more_link', 'portfolio_read_more_link' );
    add_filter( 'the_content_more_link', 'portfolio_read_more_link' );
    /**
    * Custom Read More link.
    *
    * @author Wes Straham
    * @since 1.0.0
    */
    function portfolio_read_more_link() {
    return '<a class="more-link" href="' . get_permalink() . '" rel="nofollow">Read More</a>';
    }

    // Remove post info and meta info
    remove_action( 'genesis_after_post_content', 'genesis_post_meta' );
    remove_action( 'genesis_before_post_content', 'genesis_post_info' );

    /**
    * Adds Featured Image and links it to the Post
    *
    * @author Wes Straham
    * @since 1.0.0
    */
    add_action( 'genesis_before_post_content', 'epik_portfolio_do_post_image' );
    function epik_portfolio_do_post_image() {
    $img = genesis_get_image( array( 'format' => 'html', 'size' => 'portfolio-thumbnail', 'attr' => array( 'class' => 'alignnone post-image' ) ) ); printf( '<a href="%s" title="%s">%s</a>', get_permalink(), the_title_attribute('echo=0'), $img );
    }

    /**
    * Opens Featured Images with prettyPhoto Slideshow
    *
    * @author Wes Straham
    * @since 1.0.0
    */
    /*add_action( 'genesis_before_post_content', 'epik_prettyPhoto_image' );
    function epik_prettyPhoto_image() {
    $img = genesis_get_image( array( 'format' => 'html', 'size' => 'portfolio-thumbnail', 'attr' => array( 'class' => 'alignnone post-image' ) ) );
    printf( '<a href="%s" rel="prettyPhoto[gallery1]" title="%s">%s</a>', genesis_get_image( array( 'format' => 'url', 'size' => 'Portfolio Full', 'attr' => array( 'class' => 'alignnone post-image' ) ) ), the_title_attribute('echo=0'), $img );
    }
    */

    // Move title below post image
    remove_action( 'genesis_post_title', 'genesis_do_post_title' );
    add_action( 'genesis_post_content', 'genesis_do_post_title', 9 );

    // Remove default content for this Page Template
    remove_action( 'genesis_post_content', 'genesis_do_post_image' );
    remove_action( 'genesis_post_content', 'genesis_do_post_content' );

    // Add Content for the Portfolio posts in this Page Template
    add_action( 'genesis_post_content', 'epik_portfolio_do_post_content' );
    function epik_portfolio_do_post_content() {

    if ( genesis_get_option( 'epik_portfolio_content' ) == 'excerpts' ) {
    the_excerpt();

    } else {
    if ( genesis_get_option( 'epik_portfolio_content_archive_limit' ) )
    the_content_limit( (int)genesis_get_option( 'epik_portfolio_content_archive_limit' ), __( 'Read More', 'epik' ) );
    else
    the_content(__( 'Read More', 'epik' ));
    }
    }

    // Clear float using genesis_custom_loop() $loop_counter variable
    // Outputs clearing div after every 4 posts
    // $loop_counter is incremented after this function is run
    add_action( 'genesis_after_post', 'portfolio_after_post' );
    function portfolio_after_post() {
    global $loop_counter;

    if ( $loop_counter == 3 ) {
    $loop_counter = -1;
    echo '<div class="clear"></div>';
    }
    }

    // Remove standard loop
    remove_action( 'genesis_loop', 'genesis_do_loop' );

    // Add custom loop
    add_action( 'genesis_loop', 'portfolio_loop' );
    function portfolio_loop() {
    $paged = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1;

    $include = genesis_get_option( 'epik_portfolio_cat' );
    $exclude = genesis_get_option( 'epik_portfolio_cat_exclude' ) ? explode(',', str_replace(' ', '', genesis_get_option( 'epik_portfolio_cat_exclude' ))) : '';

    $cf = genesis_get_custom_field( 'query_args' ); // Easter Egg
    $args = array( 'cat' => $include, 'category__not_in' => $exclude, 'showposts' => genesis_get_option( 'epik_portfolio_cat_num' ), 'paged' => $paged);
    $query_args = wp_parse_args($cf, $args);

    genesis_custom_loop( $query_args );
    }

    genesis();


    I love helping creative entrepreneurs build epic things with WP & Genesis.

    Follow on Twitter

    June 6, 2013 at 8:23 am #44310
    rfmeier
    Member

    Ooookay. The template file helped.

    Around line ~5 within your page_portfolio.php template, change swap this code;

    // Adds Page Title
    add_action( 'genesis_before_content', 'genesis_do_post_title' );
    
    // Adds custom content after the title.
    add_action( 'genesis_before_content', 'my_custom_content' );
    /**
     * Callback for Genesis 'genesis_before_content' action.
     * 
     * Display your custom content after the title on the portfolio page template.
     */
    function my_custom_content(){
    	
    	echo '<p>This is my custom content</p>';
    	
    }
    
    // Add page content after custom content.
    add_action( 'genesis_before_content', 'genesis_do_post_content' );
    

    This inserts the custom code after the page title, but before the page content. If you still need help setting this up, let me know.


    Ryan Meier – Twitter

    June 6, 2013 at 8:41 am #44313
    ᴅᴀᴠɪᴅ
    Member

    Perfect. Thanks a lot. Now i can just copy the content into the code.

    I wonder why the page content was never appearing? I thought that is what 'genesis_do_post_content' does.

    Anyway problem solved either way. thanks again!


    I love helping creative entrepreneurs build epic things with WP & Genesis.

    Follow on Twitter

    June 6, 2013 at 8:43 am #44314
    rfmeier
    Member

    You're welcome. I am glad I could help.

    The Genesis 'genesis_do_post_content' is for the post scope (your portfolio pages). So it was applying that code before to each one. That was my mistake.

    Good luck.


    Ryan Meier – Twitter

    June 12, 2013 at 11:07 am #45496
    pencil
    Member

    Hi, I'm wondering if there is away to add an introduction at the top of my portfolio page without getting into the php. I have my page set up via the portfolio widget in the Lifestyle theme. It sees like the only access I have is to change the page heading which is all in bold. Can I just possible add a paragraph under it with css?

    http://www.blogforart.com/my-clips/

    Thanks, Nancy

     

    June 12, 2013 at 11:18 am #45498
    rfmeier
    Member

    Nancy,

    I apologize if I am not understanding, as I don't have access to this theme-- but this page is created with a widget? Shouldn't this be a static page?


    Ryan Meier – Twitter

    June 12, 2013 at 12:14 pm #45513
    pencil
    Member

    I'm probably not being very clear but here's a screen shot of the widget. The page is fine but I'd just like to have a little description unter the title or h1 or what ever appears at the top.

    Now I don't know how to add the screen shot.

     

    June 12, 2013 at 1:34 pm #45529
    pencil
    Member

    Sorry here I am again,

    Here's the php file

    <?php
    /*
    Template Name: Portfolio
    */

    /** Force the full width layout layout on the Portfolio page */
    add_filter( 'genesis_pre_get_option_site_layout', 'lifestyle_portfolio_layout' );
    function lifestyle_portfolio_layout( $opt ) {
    return 'full-width-content';
    }

    /** Remove the standard loop */
    remove_action( 'genesis_loop', 'genesis_do_loop' );

    /** Add the Portfolio widget area */
    add_action( 'genesis_loop', 'lifestyle_portfolio_widget' );
    function lifestyle_portfolio_widget() {
    dynamic_sidebar( 'portfolio' );
    }
    genesis();

    My question is if there is a way to add a paragraph to this page?

    Thanks again, Nancy

     

     

    June 12, 2013 at 1:45 pm #45534
    rfmeier
    Member

    Nancy,

    I think I have an idea that may work. Let me fool with the code quick and I will paste the results.


    Ryan Meier – Twitter

    June 12, 2013 at 1:54 pm #45538
    rfmeier
    Member

    Nancy,

    Before I go any further, Are you able to add a text widget above the portfolio widget?


    Ryan Meier – Twitter

    June 12, 2013 at 3:15 pm #45563
    pencil
    Member

    YES!!!!

    You just made my day - Thank you so much. Nancy

    June 12, 2013 at 3:48 pm #45566
    pencil
    Member

    Well, it worked to add the text widget above the portfolio widget but for some crazy reason that threw off a lot of the css coding fro the rest of the site. Makes no sense to me.

    June 12, 2013 at 4:14 pm #45571
    pencil
    Member

    OK Last Call, I just put the default css back in and it's fine now. I'm really happy to know about adding the extra text widget at the top of the portfolio widget. Thank yo gain for solving this for me. Nancy

    June 12, 2013 at 4:37 pm #45577
    rfmeier
    Member

    Nancy,

    I am glad it worked out. Good luck.


    Ryan Meier – Twitter

  • Author
    Posts
Viewing 20 posts - 1 through 20 (of 20 total)
  • The forum ‘Design Tips and Tricks’ is closed to new topics and replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2025 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble