Welcome to this community Prezido. the_field()
function has echo in it. There is no problem with in_category()
function. You need to use get_field()
function when you echo the values of fields.
I’ve updated your code. This version should work as expected.
<?php
$post = $wp_query->post;
if ( in_category( '5' ) ) {
echo '<table>
<tr><td> ' . get_field( 'song_title' ) . '</td></tr>
<tr><td><b>Artist: </b> ' . get_field( 'artist' ) . '</td></tr>
<tr><td><b >Song Title:</b> ' . get_field( 'song_title' ) . '</td></tr>
<tr><td><b>Song Lenght:</b> ' . get_field( 'song_lenght' ) . '</td></tr>
</table>
'; }
Related Posts:
- How to end the excerpt with a sentence rather than a word?
- SQL Query for getting all posts in their latest revised state
- Listen to Post action
- How to add post count to wp_nav_menu?
- Restrict the Number of Posts an Author can Publish (over time)?
- How do I convert a mathematical Microsoft Word document to a WordPress blog post?
- Which file displays the date archive?
- how to show all post in my page-grid.php template page
- How to add padding between posts
- Plugin for sortable posts in grid [closed]
- Remove whitespace at the end of posts?
- How can I make existing custom fields easier to edit/add in my theme?
- Code Blocks with WYSIWYG in blog post
- What Can I Use To Add A Custom Button Between Publish button and Move To Trash?
- generate unique slug while inserting post
- Add filter-by-tag in the all posts admin console page
- WordPress theme ajax have_posts()
- How to show post(excerpt) from specific category on wp page?
- get posts and postmetas in assoc array
- user contributed content as custom post types
- Is 30 posts/sec considered slow for wp_delete_post?
- How to load a different header based on post format?
- Get all images out of the posts content
- How to Use PHP Code In-Page?
- Getting current post ID in functions.php
- Getting content from a single *page* of a post
- Remove certain post-formats from showing in blog?
- Email Post Attachment on wp_insert_post Action
- Can I divide the pages into categories?
- Category Foreach keeps looping?
- Are private posts visible to search engines?
- Setting posts_per_page for taxonomy term template
- display a random post thumbnail from a random category
- Posts gathered from WPEMatico feeds are being mixed in different languages. Polylang is used for language separation
- Turn On Comments On Custom Post Types in Directory Theme
- Duplicate Custom Post Type and Taxonomy Slug
- Automatically attach image to post if they have the same title
- Shortcode and whitespace formatting problem
- Remove Content after
- Using wp_list_pages() after calling query_posts()
- Delete pubished and unpublished posts with wp_delete_post?
- Proper way of establishing custom landing pages in WordPress
- Query posts by Author and/or by Tag
- How do I show posts from another wordpress installation?
- How can I determine where I want to edit in the backend (server)
- Archive template combined with post slider and regular posts
- Is there a way to add the list of recent posts into the admin sub menu on hover?
- Create a custom posts page
- How to show a custom taxonomy in the theme?
- Exclude some posts from displaying in wp_query based on some condition
- Restrict displaying posts to the poster itself (in Back-end)
- Removing all post tags except a given list
- Bootsrap carousel for post
- Create a frontpage.php and static page template
- Grab value of excerpt_length
- Defining ‘last’ class on foreach blog posts
- Deleting old posts
- How To Use Custom Tax of a Post Type
- How-to show last 5 posts
- Display hierarchical categories/sub-categories for a single post only
- Is it possible to modify posts table to only read for more recent ones?
- search form for custom fields
- posts_per_page is not working on my end
- blog post not accesible on click [closed]
- Find most used words in post titles
- $post->post_content empty while all other properties are correct
- How to highlight or show new to the particular posts list
- wp_insert_post() Add and specific ID to the body of that
- Ajax: load content from post I clicked
- How to copy a specific piece of the post to another page
- Using a meta_value or postdate to to query and orderby
- Exclude posts in home slider from sections
- Display images of related posts
- Submit New Post
- Display all tags even if they are not assigned to a post
- Display number of post published every day
- Ajaxify Post Sort
- Page Template Drop down disappears when static front page is selected
- How to create REST Based JSON API(how to modify the code below)?
- Get current user, change users post status to published
- Hide Admin posts & pages in Dashboard
- Post & Category Archives URL structure
- How to get post count including nested categories
- structure of posts and pages
- GUID to related post not in current language
- When I click edit on a post, all the content disappear. Does anyone know how to fix this?
- Page updates appear in Preview but not live version?
- Sorting Posts by Date – get_blogs_of_user_id()
- About number of posts in selected category
- WP_Query based on a custom field result
- Can I hide only one category from admin post list?
- Woocommerce – custom post type of checkout page
- ho can I get the number of the current post instead of the post id?
- Category page shows “No Posts” but I do have two assigned
- Trying hard but can’t hide featured post/page from grid
- clicking on page title
- Change a div background color on Post ID
- append $_GET parameters to post
- CSS code for “inserting a custom post divider” after each post
- how to change background color of my all post