You’re most of the way there with your current code – you’re correct that you can wrap the condition around what you’ve already got. The is_page()
function allows you to check for an array of pages, so as long as you plan to specify pages manually, all you need to do is
<?php if (is_page(array(11, 'about', 'Contact Us')) ) : ?>
<p><strong><?php echo get_the_title( $post->post_parent ); ?></strong></p>
<?php endif; ?>
is_page()
accepts page ID, slug (from the permalink), and title. You’ll probably want to pick whichever of those makes the most sense to you personally and use the same piece of data for all the pages, just so it’s easier to identify which pages it applies to if you come back to it later.
Do note that whatever code you write, you’ll want to write it inside a child theme. That’s because when you update your theme, it will overwrite any customizations you’ve done.
Related Posts:
- How to include checkbox in widget backend form?
- Using register_activation_hook in classes
- Upgrading PHP version results in “Use of undefined constant WP_CONTENT_DIR” warning?
- How to hide get_theme_mod if field empty
- renaming an admin menu item with decimal array index number
- How to get the original price of the product in woocommerce?
- How to make sure that only one wp_cron() runs at a time?
- Replacing the NavWalker dropdown element
- Fatal error: Call to undefined function wpsc_cart_item_count()
- No wp-config.php file on local install of wordpress – site still displays
- Widgets not showing in my custom theme
- Edit category output
- Woocommerce Custom CSV export
- integrating external php library into wordpress- the right way
- To echo or not to echo?
- Different background-image by category
- Add a Different CSS Class Into The Body Tag of Different WP Pages
- How to limit the content coming from wordpress shortcodes?
- What is the fastest way to load PHP functions that are only used in one theme template?
- Writing scripts using WordPress / WooCommerce classes?
- storing wp_head in a variable?
- Get taxonomy terms only of the WP_Query current posts
- Change description on specific WooCommerce product status change
- How do I attach a php file to an arbitrary slug and still have access to the wp-core functions?
- Woocommerce redirect thankyou page based on product ID doesn’t empty Cart
- How to deal with checkboxes in edit page?
- Is_template how to add one more template [closed]
- Displaying Hierarchical custom taxonomy
- Open post-content in archive page in a Modal box with bootstrap
- Creating own shortcode – echoeing php variable based on JS variable
- How to modify URL (add GET values) after front end form submission?
- Sort meta-value in the sequence array in pre_get_post
- How do I link a button I created in theme customizer to a function?
- Error: options page not found
- Filtering a Database Query
- anyway to put inside a $outprint=sprintf()
- Can’t save php string to a custom field
- Blob file download problem
- What does $_GET[‘iphone’] do?
- Appended comments but they show up above the content instead of below
- get_template_directory adding FTP root folders in urls
- What’s the best way to include PHP code in pages?
- Is there any wordpress plugin to upload images and captions to multiple pages once
- Removing the first 8-10 letters from a post?
- Line breaks inside shortcode variable
- Site Health says I’m running an older version of PHP even after I upgraded to 7.4.4
- WordPress REST API register_rest_route give a 500 error
- Where to insert redirect code based on http_referer?
- Changing the order of custom fields in the dashboard for Woocommerce variable products [closed]
- woocommerce wc_create_order(); is creating multiple orders instead of one?
- Override Admin menu icon
- Trying to get property of non-object in WordPress Breadcrumbs
- Delete database record using plugin from admin panel
- Post not populating for custom post type based on category selection
- How to display success message correctly and delete it when the page is refreshed
- Infinite Loop – WP_Query
- call_user_func_array() expects parameter 1 to be a valid callback, function ‘———-‘ not found or invalid function name
- How can i make a search box to search by custom field
- ‘Bones’ theme: Load stock scripts in footer instead of header?
- go to home page when i select default in select-box
- Display Custom Field in Sidebar if Value is Present
- Error while loading wordpress site “Fatal error: Uncaught Error: Call to undefined function twentytwentyone_the_html_classes() in /home
- Database entry removed on browser refresh, Ajax PHP jQuery
- Hide specific product from Woocommerce if the logged-in user has already enrolled into the course
- How to find which .mo file is responsible for displaying a particular localized string?
- wp_Query with mutuplea values returns all posts
- is it possible for a URL to filter by tag
- How to stop hiding buttons forward / backward in pagination?
- Preserving backslashes in post_content
- Add to cart quantity dynamic
- Infinite looping next post link within a certain category on a post
- WordPress PHP version
- Woocommerce textarea format ignored
- Windows Setup: Error establishing a database connection
- Pass product object to javscript
- How to display post_content from database in different on template page?
- Add Text Area To Child Theme’s Home Page
- Beginner Developing Theme with Bootstrap – NavMenu question
- remove blank space where sidebar was
- Using Tag Groups: Displaying groups and adjacent tags of current post
- How to add thumbnails from recent posts to owl-carousel in wordpress automatically?
- Display 6 most recent post on homepage?
- Custom theme: adding unwanted tags in the content
- File path for attachments outside of wp-content/uploads
- Closed html class after counter = multiple of 3
- How to save the output of php variables used in inline css code to the main style.css?
- How can i call the facebook #hashtag images on my site
- Error trying import one category on page
- URL prefix to include one PHP page
- Crop images in both sides on wordpress [duplicate]
- Query category name by variable
- archive per year with monthly
- I am unable to fetch json data from wp_db
- Check if username doesn’t exists
- Add multiple HTML attributes to an Elementor button
- Customize the summary table of an order in the email
- How to sort custom sortable column by custom table value
- How to disable page create for custom post type, but allow a page with the post types slug to be created?
- WooCommerce Modal Fly cart on add to cart – With AJAX
- /page/2/ redirect to 404