Community Forums › Forums › Archived Forums › Design Tips and Tricks › Advanced Custom Fields & Genesis Hooks (Output Issues)
- This topic has 2 replies, 2 voices, and was last updated 10 years, 1 month ago by Cotton Rohrscheib.
-
AuthorPosts
-
March 6, 2014 at 8:58 pm #93795Cotton RohrscheibMember
We started this project w/ Agentpress Listing Plugin w/ the Prose Child Theme and quickly discovered that the client was looking for more than the plugin offered in terms of layout, etc. -- so we implemented the Advanced Custom Fields plugin and have managed to configure the site the way the client wants from an entry standpoint but we have some issues w/ the layout (or output of the data) and I'm just not for sure which hooks we should be using.
----- SEARCH RESULTS PAGE (ARCHIVE OR LISTINGS -----
On the Search Results Page for the Listings, the Client wants to display the Featured Image for the Listing (which we've handled) and also the following advanced custom fields: County, Acres, Price, Type, Agent. We have this working pretty well w/ the exception of the last listing on the page: http://rohrscheib.net/sandbox-014/?s=&post_type=listing&county=&acreage=&property_type=&listing-agent=&state=
This is the custom code we are using to accomplish this:
/** Custom Code for Advanced Custom Fields: Search Results (Archive) */add_action( 'genesis_post_content', 'custom_stuff2'); function custom_stuff2() { echo '<b>County: </b>'; the_field('county'); echo '<br/>'; echo '<b>Acres: </b>'; the_field('acres'); echo '<br/>'; echo '<b>Price: $</b>'; the_field('price'); echo '.00<br/>'; echo '<b>Type: </b>'; the_field('type'); echo '<br/>'; echo '<b>Agent: </b>'; the_field('agent'); echo '<br/>'; }
----- INDIVIDUAL LISTING PAGE(S) -----
We also have this page constructed w/ the fields the client wants, including (County, Acres, Price, Type, Agent, -- and we've added Description, Aerial Map, Location Map, and Photos to this page by using the following custom custom code & hook. Here's an example listing page: http://rohrscheib.net/sandbox-014/listings/test-listing-heber-springs-property/
/** Custom Code for Advanced Custom Fields. Individual Listings. */
add_action( 'genesis_after_loop', 'custom_stuff'); function custom_stuff() { the_field('description'); echo '<br/>'; echo '<b>Aerial Map: </b>'; the_field('aerial_map'); echo '<br/>'; echo '<b>Location Map: </b>'; the_field('location_map'); echo '<br/>'; echo '<br/>'; the_field('photos'); }
----- SUMMARY / QUESTIONS -----
As you can tell from both examples I've sent over, I've picked either the wrong "hook" or something and it's not giving me what we are looking for. Also, if you will notice on the homepage of the website: http://rohrscheib.net/sandbox-014/ --you will notice that the custom fields are also showing up at the bottom of the page even though the "home page" isn't a listing.
Does anyone have any suggestions? This is sort of new to me, thanks for your help in advance,
Cotton Rohrscheib
http://cottonrohrscheib.comMarch 6, 2014 at 9:30 pm #93804coralseaitMemberHello,
On your first question, it appears that something is happening outside of the loop or different on that listing. What if you delete it and re-add, is it the same? What are you doing, if anything to the query args? Edit, thinking on it may be related to second question below because of the action hook firing with query populated. Not sure.
On your second question, because you've hooked into genesis_after_loop the action fires after the genesis loop anywhere it is used (which is every template page in most themes) so that def isn't the desired behaviour for your goals. Have a look here for a better hook http://my.studiopress.com/docs/hook-reference/
You may want to look into a custom genesis loop instead of adding an action after the loop standard genesis loop if you can't find something that better suits your needs. You may also want to look into WP Query if you need to completely customize your query args and write your own front end.
March 7, 2014 at 11:38 am #93846Cotton RohrscheibMemberThanks so much for your response, I'm going to get w/ another one of our developers and pick his brain on this too --and definitely will try to get my head around custom genesis loops and wp query as well. I might have more questions once I get further a long into the process, thanks for taking the time to offer up some suggestions!!
Cotton Rohrscheib
http://cottonrohrscheib.com -
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.