Jump to content


Photo
- - - - -

Display Custom Fields in Sidebar


  • Please log in to reply
10 replies to this topic

#1 blzalewski

blzalewski

    Member

  • Members
  • 19 posts
  • Country: Country Flag

Posted 27 June 2012 - 01:22 AM

I'm trying to display two custom text fields (website_name and website_rating) in the Primary Sidebar and have failed to do so. If the post is in the Websites category, I want the widget displaying the data to be activated. What is the most direct way of accomplishing this? I have tried searching in the forum/all of over the internet and have failed to come up with a working solution.

#2 catrina

catrina

    Advocate

  • Members
  • 12345 posts
  • LocationCalifornia
  • Country: Country Flag

Posted 27 June 2012 - 02:34 AM

The only way would be to make changes in the code, which requires that you use the Base theme in PageLines Framework. I've been searching around, as well, but couldn't find a solution. Have you tried searching for a plugin that would allow you to do this?: http://wordpress.org/extend/plugins/

#3 blzalewski

blzalewski

    Member

  • Members
  • 19 posts
  • Country: Country Flag

Posted 27 June 2012 - 04:49 AM

Thank you so much for the prompt response Catrina. Any idea on how I could modify the Base theme to do this? I have looked up how to do this but all the possible solutions I have found conflict with the Pagelines Framework.

#4 Rob

Rob

    One Smart Egg

  • Members
  • 13575 posts
  • LocationEast Coast, USA
  • Framework Version:The Latest, of course
  • Country: Country Flag

Posted 27 June 2012 - 07:47 PM

Hi, The issue you're facing is really not theme related in any way, but WordPress. We don't create the widgets. But, that said, you can. You may also use something like Shortcode Exec PHP to create a shortcode and use a standard text widget to apply it. Creating a custom widget is something you'd learn about at www.wordpress.org.

#5 blzalewski

blzalewski

    Member

  • Members
  • 19 posts
  • Country: Country Flag

Posted 28 June 2012 - 03:06 AM

all of the solutions I have come across ask me to add code to functions.php and the last time I did this my website crashed

#6 catrina

catrina

    Advocate

  • Members
  • 12345 posts
  • LocationCalifornia
  • Country: Country Flag

Posted 28 June 2012 - 03:22 AM

Depending on where the code is placed in functions.php, the site may crash. Also, there may be something wrong with the code itself.

#7 blzalewski

blzalewski

    Member

  • Members
  • 19 posts
  • Country: Country Flag

Posted 29 June 2012 - 09:33 AM

Thanks again for the prompt response Catrina. Rangelone.. this has something to do with pagelines because if I weren't using pagelines this would be a very simple addition. Replace: With: ID, "sidebar", true); get_sidebar($sidebar); ?> Pagelines builds the sidebar differently than a normal Wordpress set up and I can't figure out how to do it or find any documentation relating to it. I should be able to add that one line of code in somewhere I just can't figure out where. Also, if I can't figure out how to do this through Pagelines then I would like to figure out how to disable Pagelines' control of sidebars. Any ideas?

#8 blzalewski

blzalewski

    Member

  • Members
  • 19 posts
  • Country: Country Flag

Posted 29 June 2012 - 09:34 AM

Maybe I could create a second sidebar.php file called sidebar2.php and somehow have that sidebar2.php called on the pages I need it to be called on?

#9 Danny

Danny

    Is Awesome!

  • Moderators
  • 17124 posts
  • LocationManchester, UK
  • Country: Country Flag

Posted 29 June 2012 - 11:25 AM

Hi, Have you tried this plug-in ? http://wordpress.org...m-field-widget/ I have no experience with the plug-in itself but from the description, it may be what you're looking for.

#10 jbrouwer

jbrouwer

    Super Member

  • Members
  • 191 posts
  • Country: Country Flag

Posted 29 June 2012 - 02:01 PM

This code in functions.php works for me:

 add_action('pagelines_inside_top_sb_primary', 'my_custom_sidebar');
	function my_custom_sidebar(){
	?>
		<div class="widget-pad">
	        <h3 class="widget-title">My custom widget:</h3>
				<div class="my-class-to-style">
					Some text to display.
					<?php
					global $wp_query;
					if(is_object($wp_query->queried_object) && $wp_query->queried_object->ID){
					$field = get_post_meta($wp_query->queried_object->ID, 'key-of-custom-field', true);
					echo $field;
					}
					?>
				</div>
		</div>
	<?php
	}

Just change 'key-of-custom-field' into the key you would like to display.
  • CliffordP likes this

#11 catrina

catrina

    Advocate

  • Members
  • 12345 posts
  • LocationCalifornia
  • Country: Country Flag

Posted 29 June 2012 - 03:42 PM

Thanks for posting your solution, @jbrouwer