• 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

How to hide custom fields on archive pages with 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 › How to hide custom fields on archive pages with php?

This topic is: resolved

Tagged: Custom fields

  • This topic has 3 replies, 3 voices, and was last updated 6 years, 7 months ago by Netzlichter.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • November 26, 2018 at 11:41 am #224603
    Netzlichter
    Participant

    Hi there!

    I'm using Simple hooks plugin and the following code to show my custom fields under my blog post:
    - genesis_after_entry_content Hook
    Executes after the entry content
    genesis_do_post_content()
    -> <?php the_meta(); ?> (execute php)

    My custom fields show up under my single post. But they show up on my archive pages too. How can I hide the custom fields from all other pages?

    That functions hides the post meta from archive pages: is there something similiar for custom fields?

    `/* Remove entry meta in entry footer
    add_action( 'genesis_before_entry', 'beautiful_remove_entry_meta' );
    function beautiful_remove_entry_meta() {

    //* Remove if not single post
    if ( ! is_single() ) {
    remove_action( 'genesis_entry_footer', 'genesis_entry_footer_markup_open', 5 );
    remove_action( 'genesis_entry_footer', 'genesis_post_meta' );
    remove_action( 'genesis_entry_footer', 'genesis_entry_footer_markup_close', 15 );
    }

    }`

    Custom fields on WordPress.org: https://codex.wordpress.org/Custom_Fields

    I don't want to hide this information with css, becasue of load times...

    Big thanks in advance!

    November 26, 2018 at 3:00 pm #224608
    Victor Font
    Moderator

    You didn't explain how you are displaying the custom fields, but most likely you can use the WordPress conditional is_archive to remove the action. https://codex.wordpress.org/Conditional_Tags


    Regards,

    Victor
    https://victorfont.com/
    Call us toll free: 844-VIC-FONT (842-3668)
    Have you requested your free website audit yet?

    November 26, 2018 at 3:39 pm #224609
    Brad Dalton
    Participant

    Another option is to remove simple hooks and use code like this.


    Tutorials for StudioPress Themes.

    November 27, 2018 at 3:37 am #224616
    Netzlichter
    Participant

    My solution is:

    add_action( 'genesis_before_entry', 'beautiful_add_the_meta_to_post' );
    function beautiful_add_the_meta_to_post() {
    	
    	//* Show if single post
    	if ( is_single() ) {
    		add_action( 'genesis_after_entry_content', 'the_meta' );
    	}
    
    }

    It shows "the_meta" (custom fields) under my post content only.

  • Author
    Posts
Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘How to hide custom fields on archive pages with php?’ is closed to new 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