danefoster
Forum Replies Created
-
Forum: Fixing WordPress
In reply to: Generate Menu Item from CURRENT logged in user…Thanks for the heads up regarding the bump. Don’t usually do that. Anyway, I have explored all options and considered what you are saying regarding the password protected pages/posts. It just seems… odd/low tech in a way when we are targeting high end clients. I guess what I’m saying is that people are used to logging in with a username and password and being taken to ‘their page’ on whatever site.
With what your suggesting they would have to keep that link around which could end up being rather long https://www.sitename.com/clients/thisclient and still need their password. I appreciate your feedback, and while that would work, we are still looking for a solution that includes a ‘my projects’ type menu item along with an automatic redirect to their page upon login. Thanks for your response.
Forum: Fixing WordPress
In reply to: Blog Image Problem [what do I call this?[Hello. I won’t pretend to be an expert, but lorro is on to something. If you go to gtmetrix.com and plug in your site address, then click on the Timeline tab you will see that A) your page load time is really, really slow, and B) that several of your thumbs (the ones in red) are doing exactly what lorro is suggesting.
Aside from taking lorro’s advice I would definitely recommend making your images smaller and/or compressing them. Hope this helps.
Forum: Fixing WordPress
In reply to: Reduce White Space on Homepage – How?There is most likely a way to do this in your theme that does not require you adjusting the padding. I would really like to help but your question is difficult to understand. So when you remove the ‘vertical center’ your text is no longer middle aligned?
It looks like the Honeymoon theme uses ‘Drag and Drop Builder’ which is some form of a visual composer. Usually in these you would hardly ever need to touch the padding or margins to accomplish what you are talking about. Inside the text editor of their ‘Text/Image Block’ there is a middle align button, and most times each element of a theme or the row itself can be middle aligned.
My advice is to immediately reset your margins and padding to zero and to play around inside the editing functions of the rows and elements. Hope this helps.
Forum: Fixing WordPress
In reply to: Generate Menu Item from CURRENT logged in user…Bump…
Forum: Fixing WordPress
In reply to: Conditional Custom Fields — Only display if value is a link?Cyril, I simply cannot thank you enough. Not only is your code much cleaner and easier to read/edit–it works perfectly! I will avoid curly braces in my future endeavors to learn proper PHP. Again, thank you for your selfless effort to help me, it is truly appreciated! DF
Forum: Fixing WordPress
In reply to: Conditional Custom Fields — Only display if value is a link?Cyril, thank you so much for your response. I should have just put in my code first, and will here below. I attempted your strpos function method, and then another function strpbrk from the link that you gave me. The problem with both is that they are both looking for a string when in fact I am feeding them an array. I get this error:
Warning: strpos() expects parameter 1 to be string, array given
Here is my code. Again to explain, the top portion is simply getting all my pages to list using ‘normal’ WordPress functions without using a db query. The bottom portion, from the $keys_to_show variable on down, is the bit that I’m trying to figure out. Being totally candid, I am worthless at PHP and pieced this together from trial and error, but it works. I left the strpos line in there that is giving me the error–maybe I’m putting it in the wrong place? Maybe there isn’t a function that looks through arrays?
<?php $mypages = get_pages( array( 'child_of' => 8, 'sort_column' => 'post_title', 'sort_order' => 'ASC' ) ); foreach( $mypages as $page ) { ?> <div class="document-page-result"> <h5><a href="<?php echo get_page_link($page); ?>"><?php echo $page->post_title; ?></a></h5> <?php $meta_values = get_post_meta($page->ID); $keys_to_show = array('custom_field_key_1', 'custom_field_key_2', 'custom_field_key_3','custom_field_key_4', 'custom_field_key_5'); // array of keys to show if (strpos( $keys_to_show, '<a' ) !== false ); { foreach ($keys_to_show as $key) { if( array_key_exists($key, $meta_values) ) { $values = $meta_values[$key]; foreach ($values as $value) { echo "$value<br />"; } } } } ?> </div> <?php } ?>
Getting back to the original problem/question–attempting to look through all the custom field keys and only display the ones that are links, instead of all of them like it is doing now. Thanks again in advance, I genuinely appreciate it.
Forum: Your WordPress
In reply to: Any suggestions for making this website betterHonest opinion, here it goes. I would start with the above comment, remove the repeating background image. If they have made it to your site, they already know the address. Second, I would center your site/main container. If you don’t know the CSS to do this, google it. Off the top of my head I believe it is {margin: 0 auto;} Third, I would make your header much shorter so that people don’t have to scroll down to see the main content. Fourth, I would make your landing/home page (after you’ve shrunk up your header) a gallery page.
You have some very beautiful photography. Again, I would have your landing page include some sort of gallery plug in to show that off. Best of luck.
Forum: Themes and Templates
In reply to: [Responsive] Add another content area to bottom of homepageWant to help a guy out because others have taken time to do the same for me. Thought that that was fairly self explanatory.
Forum: Themes and Templates
In reply to: [Responsive] Add another content area to bottom of homepagestanford ian,
Hello, will attempt to pay it forward as others have done for me on these forums. I am building a rather complex site using the Responsive theme as my base, so I am fairly familiar. Anyway, I would recommend the following:
1. make sure you are using a child theme
2. make a custom page template using your Home page
3. then simply add another div below your widgets and above the footer
4. whatever you name your new div (class), you will need to add/edit the CSS for it to make sure that it expands full widthAlso, make sure that your new div is not ‘inside’ the main content div as these have their widths set by the CSS styling from lines 261 to 307.
I really hope this helps. I rarely am ever here so good luck, if you need help with numbers 1 or 2 simply youtube it or head to the WP codex which is actually very well written and easy to understand.
Forum: Fixing WordPress
In reply to: All Custom Field Values AND Page TitlesFor any who may follow. With much help, time and effort my issue has been solved. Original problem: List all pages (or specified ones) and all of the Custom Field values (or specified ones) for each page. How this was accomplished:
<?php $mypages = get_pages( array( 'child_of' => 8, 'sort_column' => 'post_title', 'sort_order' => 'ASC' ) ); foreach( $mypages as $page ) { ?> <h5><a href="<?php echo get_page_link($page); ?>"><?php echo $page->post_title; ?></a></h5> <div class="entry"> <?php $meta_values = get_post_meta($page->ID); $keys_to_show = array('phone_number', 'fax_number', 'regular_mail'); // array of keys to show foreach ($keys_to_show as $key) { if( array_key_exists($key, $meta_values) ) { $values = $meta_values[$key]; foreach ($values as $value) { echo "$value<br />"; } } } ?> </div> <?php } ?>
The top portion of the code gets the list of pages using the get_pages() function. In this case, it is grabbing all pages that are a child of page ID ‘8’, and displaying them by post_title, and sorting them alphabetically by ‘ASC’. The proper link back to each page is set by using get_page_link($page), the $page variable being the result of the foreach loop result for each page in the list. We display each result with $page->post_title which is showing each $page result from the get_pages() function as the post_title.
The second portion of the code displays the Custom Field values for each page. We accomplished this by using get_post_meta($page->ID) to select the pages from the above function, then using the $keys_to_show array to select which Custom Field values to display.
Hope this may help somebody in the future, thanks to vtxyzzy who made this possible.
Forum: Fixing WordPress
In reply to: All Custom Field Values AND Page TitlesThis works beautifully, just added a line break in with value. May I ask how this works? More specifically why the first bit of code worked, but was random, and what changed in the second block to correct it?
Forum: Fixing WordPress
In reply to: All Custom Field Values AND Page TitlesJust tried that, brilliant. The only odd thing is that the results of the array are displayed in a sort of random order. Meaning one store shows phone, fax, address while the next store shows phone, address, fax while the next one shows address, fax, phone. Just sort of odd. Any idea why? Otherwise this is exactly what I was looking for and cannot thank you enough for your help.
Forum: Fixing WordPress
In reply to: All Custom Field Values AND Page Titlesvtxyzzy, thank you once again for your response. Here is what I’ve got:
<?php $mypages = get_pages( array( 'child_of' => 8, 'sort_column' => 'post_title', 'sort_order' => 'ASC' ) ); foreach( $mypages as $page ) { $meta_values = get_post_meta($page->ID); $keys_to_show = array('phone_number', 'fax_number', 'regular_mail'); // array of keys to show foreach ($meta_values as $key=>$values) { if( in_array($key, $keys_to_show) ) { foreach ($values as $value) echo "$value<br />"; } } ?> <h4><a href="<?php echo get_page_link($page); ?>"><?php echo $page->post_title; ?></a></h4> <div class="entry"><?php echo $value; ?></div> <?php } ?>
But it is not working. It echoes the list perfectly above the link/title from the original echo statement and returns all three Custom Field values of phone_number, fax_number, and regular_address. However, I can’t seem to get it down where it needs to go! So close!! The bottom
echo $value
only returns the last value. I don’t get it but I almost certain it has something to do with the curly braces. I am ignorant to what they do but it seems they should ‘include’ the bottom portion of coding. So I guess the final question is: How do I get the array that I’ve returned into the correct/lower echo call of $value? Many thanks again. DFForum: Fixing WordPress
In reply to: All Custom Field Values AND Page TitlesI wanted to update my findings for those who may follow, and also ask for additional help as I am getting very close to reaching my goal. Original question: many pages as a list on one page, each list item as a link and ALL Custom Field values. So I have a page titled Stores, need list of all stores; AlphaStore, BravoStore, CharlieStore etc. (with titles as links to their respective pages) and would like all custom fields displayed under each. I have solved 90% by using this:
<?php $mypages = get_pages( array( 'child_of' => 8, 'sort_column' => 'post_title', 'sort_order' => 'ASC' ) );//This lists all pages that are a child of '8' which is the parent Stores. Sorted by post_title, alphabetically foreach( $mypages as $page ) {//This loops through the array values individually ?> <h4><a href="<?php echo get_page_link($page); ?>"><?php echo $page->post_title; ?></a></h4> //get_page_link($page) inserts correct link address to individual pages //$page->post_title lists page <div class="entry"><?php echo $content; ?></div>//$content is nothing yet, where I need help <?php } ?>
So I have my list of all pages that are a child of Stores, alphabetically, as links, and linked to the proper address. The only thing that I cannot figure out is how to get ALL Custom Field values to show up the following <div> as the $content variable. Here is the odd part, if I insert
$content = get_post_meta($page->ID, 'phone_number' , true);
just above the foreach loop, it will return all the matching phone numbers for each store. However, when I simply use get_post_meta() which according to the Codex is supposed to return all values, it simply reads ‘array’ in black text, not the values. I feel that I am VERY close, if somebody could help me out and bring this month long journey to an end it would be greatly appreciated.Forum: Fixing WordPress
In reply to: All Custom Field Values AND Page Titlesvtxyzzy,
First, thank you for taking the time to try and help me. I tried plugging in this code and it doesn’t seem to work. I am admittedly not a PHP coder, so I really don’t know where to begin to make it work. I hate to ask for favors as you already have gone out of your way, but in an effort to learn instead of simply asking for an answer, could you explain the above code and what it is trying to do? Thank you very much again, DF