Forum Replies Created

Viewing 4 posts - 91 through 94 (of 94 total)
  • Author
    Posts
  • in reply to: adding custom fields #350539

    Hi there,

    I have copied the file loop-index.php to the child theme folder added the following code and it does not work – nothing is displayed:

    echo get_post_meta( $the_id, 'key', true );

    I have 4 custom fields in each language. I need to display them in a specific order under the post title on all pages where t=posts are (eg. blog roll, single post, specific category/tag post)

    Below is the code I used in twenty ten a couple of years ago. It illustrates the principle:

    <div class="pprow">
    		<?php $myid = $post->ID; // Assign this using a variable, or however you were before, eg. $post->ID
    
    		$data = $wpdb->get_results("
    		SELECT * FROM $wpdb->postmeta WHERE post_id = $myid
    		AND meta_key NOT LIKE '\_%'
    		ORDER by (CASE WHEN meta_key = 'Composed in' THEN 0
    				WHEN meta_key = 'Duration' THEN 1
    	       			WHEN meta_key = 'Instrumentation' THEN 2
    	       			WHEN meta_key = 'Movements' THEN 3 
    	       			WHEN meta_key = 'Rok' THEN 4
    	       			WHEN meta_key = 'Czas' THEN 5
    	       			WHEN meta_key = 'Instrumentacja' THEN 6
    	       			WHEN meta_key = 'Części utworu' THEN 7 END)
    		"); // meta_key ASC - assign the field to sort e.g. meta_id, meta_key, etc. or specify order using CASE WHEN
    
    		if( !empty( $data ) ) {
    			foreach( $data as $result_object ) {
    				print '<div class="ppmeta-key">';
    				print $result_object->meta_key;
    				print ': ';
    				print '</div><div class="ppmeta-value">';
    				print $result_object->meta_value;
    				print '</div>';
    				print '<br />';
    							}
    					}
    		?>	
    		</div>

    Can you please advise how to implement it in Enfold?

    Many thanks,
    Peter

    • This reply was modified 10 years ago by TheElear.
    in reply to: Enfold child theme #350409

    You can close this thread now.
    regards,
    P

    in reply to: Enfold child theme #350408

    Many thanks,
    P

    in reply to: adding custom fields #350247

    Hi Elliot,

    Shall I copy loop-index.php file to enfold-child theme folder?

    regards,
    Peter

Viewing 4 posts - 91 through 94 (of 94 total)