Forum Replies Created

Viewing 15 replies - 76 through 90 (of 546 total)
  • I just use href=”/”

    If you are referring to having custom layouts for each “type” of post (ie. category of post) then you CAN create custom category.php template files… just duplicate the category.php file and append the category number like so: category-3.php using (of course) the appropriate category number which you can easily get by hovering over the category in question in your admin in the category list.

    Within the heirarchy, WordPress will default to using the custom category-x.php file if it is available when displaying a number of posts for that category, for example, if you click the link for the category created from using wp_list_categories();

    Understanding what MichaelH suggests above is pretty required to understand how the whole WordPress application manages data and files.

    Good luck with it!

    Nevermind… going on what was suggested above, I put the custom field data into $vars like:

    $prodname = c2c_get_custom('MMTname');
    $prodprice = c2c_get_custom('MMTprice');

    and then later, when calling the cart button, used them, like so:

    <?php echo print_wp_cart_button_for_product($prodname, $prodprice); ?>

    Thanks for pointing me in the right direction!

    This is a variation on that question, but definitely related… in the same cart plugin, how could you get the data from a custom field that contains the product name and price into the cart button template code? For example, the cart uses:

    <?php echo print_wp_cart_button_for_product(‘PRODUCT-NAME’, PRODUCT-PRICE); ?>

    and the info I want is stored in custom field keys “MMTname” and “MMTprice”…. I am already displaying this data (and more) from custom fields in the same page.

    Help greatly appreciated!

    @myran

    Did c2c’s answer help you? If it solved the issue, please mark your post resolved so the rest of us can take advantage of the solution, thanks!

    BTW, I LOVE this plugin. When I use other custom write page plugins, I almost always fall back on this plugin for display – either because the authors of the custom template or write pages don’t have English documentation or tutorials out there for them are out of date.

    csc_get_custom is my FAVORITE plugin! Thanks!

    BTW, just want to say that from your first post, it sounds like that was a huge chore! yikes!

    Maybe those should be categories so you can use the post_is_in_descendant_category function

    https://codex.www.ads-software.com/Function_Reference/in_category#Testing_if_a_post_is_in_a_descendant_category

    https://codex.www.ads-software.com/Conditional_Tags

    Read that, especially the part about is_tree() in snippet#3

    Add that to the functions.php file in your theme, per directions or to the includes functions.php (though you may end up having to back this file up or redo the addition after upgrades)

    is_tree(‘ID#’) (id of the parent page, which you can get from the list of pages in your admin by hovering over a page listed and looking in the status bar for the post number (pages are posts, too)

    Use conditional logic with the is_tree function to echo a style for the parent and immediate sub-pages (note, this doesn’t apply to sub-subs which can be a GOOD thing)

    See also:
    https://www.ads-software.com/support/topic/320406?replies=8#post-1257337

    hth

    but of course, this doesn’t go down 5 levels…. still, you could add the levels in the is_tree logic

    www. isn’t a complete URL… it would have to be at least https://www.mysite.etc

    And if this is the FRONT page (setting a static page to be home), use is_front_page() rather than home… because it isn’t home if you set it to be front page.

    <div class=”contentBanner”><?php if(is_front_page()){
    echo ‘<img src=”‘.bloginfo(“template_directory”).’/imagefolder/nameofimage.jpg” />’;} else {} ?></div>

    using elseif and else

    But this means you have to hardcode the image to be used for each page — as opposed to usigng is_tree() to echo the image src, which allows for all the sub pages of said parent to share the same header image.

    HTH

    Thread Starter syncbox

    (@syncbox)

    Hmmm… this seems almost bass-ackward, frankly. So… if you remove the default Page, Post and Link admin screens, you’re left with the custom more-fields ones (currently for me, Products and Contact)… but none of the actual pages created show up when I click the Edit links in either… though I can opt to click the “all” or other filter links and see them….

    And oddly, unlike the default Page or Post admin menu tools, when you click on the “Product” heading, it goes to Add New rather than Edit (the list)… it all seems anti-default WP behavior.

    Here’s what I expect to see:

    1) same interface for creating boxes, fields and types (stop using the word post for this, though, it only adds to confusion).

    2) Don’t create new “types” in the left column where page and posts already are and don’t offer to turn those off.

    3) Instead, IN the interface for each of those, offer any “type” that has been created IN A MENU ON THE LEFT< like in Attributes (eg. template, parent, TYPE) and when that is chosen, THEN OFFER the boxes selected to display for that TYPE.

    Stop using Screen Options to control this, it’s lame.

    My two, now until that happens, I’ll go find a plugin that works as expected. I am generally happy with being able to create groups and display the fields but the point was also to make the CMS end of things EASIER for someone who doesn’t understand html or wordpress all that well.

    I think they’d be more confused than I with the current setup, sorry.

    Thread Starter syncbox

    (@syncbox)

    Actually, no, this isn’t resolved… it’s a mess.

    I would expect my more-fields post types to contain the boxes I checked for them (eg. a “product” post-type based on a page and set to include my more-fields box group of “product details” fields…. and any other pertinent default boxes I’ve checked off for that post type.

    That isn’t what happens. If the default post and page types have their screen options/boxes set to not show the custom more-fields stuff, the custom more-fields post types won’t show them, either and won’t even offer them in the Screen Options.

    If the default post and page types DO offer the more-fields boxes, then they ALL display on the default post and page screens, including the custom more-fields post types.

    Useless, imo, the way it is. Screen Options should be stored on a per-page basis, not in some global manner. Is this because it’s poorly designed in WordPress itself or some effect of installing More Fields? At this point, I am not sure because I never had the need to restrict what was on the screen until implementing more fields for just that purpose (among others)

    I will investigate other plugins at this point, I think.

    Thread Starter syncbox

    (@syncbox)

    Nevermind… I think I have the answer… you have to EDIT the base post types… (posts and pages) to set the defaults to REMOVE any new custom more fields boxes/fields added…

    They should NOT be shown by default, imo… but it seems that they are shown by default. Next time I add a new box group of fields, I’ll test to see if it gets checked to be shown by default on the WP Page admin screen….

    Thread Starter syncbox

    (@syncbox)

    Works great! Thanks again, Mike. Great Plugin…. I like putting it into the template because it keeps it safely tucked away from uninformed “editors” and they can edit labels and text and such from the plugin’s settings anyway…

    Or, even easier, install Coffee to Code’s “get custom fields” plugin… it’s great, especially in conjunction with more fields.

    (from your wp install plugins (Add New) search for get custom.

    Let’s say you have a key in a field for more fields called “Company Name”… using get_custom’s params, you can specify what comes before, after, between, what to do if no value is there, what to do if there are several values, what to add after the last value instance and more:

    Read about get_custom here:

    https://coffee2code.com/archives/2004/06/30/plugin-get-custom/

    The code would look something like:
    <?php echo c2c_get_custom('Contact Name','<ul id="cudetails"><li id="cu-name"><strong>','</strong></li>'); ?>

    as an example. Dead easy to use, but there are many more options via the params than that example shows… as I would have the final key add the closing </ul> tag…

    HTH

    I think you have to use elseif and else in there rather than all those “ifs”… without going into what it is you are trying to do, did you try:

    <?php
    if (in_category(‘education’)) {
    {echo ‘class=”educationcontent”‘;}
    elseif (in_category(‘healthcare’)) {
    {echo ‘class=”healthcarecontent”‘;}
    elseif (in_category(‘business & industry’)) {
    {echo ‘class=”businesscontent”‘;}
    elseif (in_category(‘public sector’)) {
    {echo ‘class=”publiccontent”‘;}
    else {//the default action if not any of the above }
    ?>

    I’m no php programmer, but…

    and I’d move the php inward, since you KNOW you want a class written, there’s no need to put that part into the code (saving bytes) because you could write
    <div class=”<?php /*all the logic above*/ ?>”>

    just my two. hth, and good luck with it!

    Thread Starter syncbox

    (@syncbox)

    I’ll look at using CSS for it, but even that is something that can be overwritten because it’s in the admin, not the theme…

    I’ve actually started playing with more fields, which does work in 2.8.5 despite warnings, though you have to change a couple of lines of code in a couple of files.

Viewing 15 replies - 76 through 90 (of 546 total)