• Resolved Fred Atkinson

    (@fatkinson)


    Yannick,

    Is there any way to configure a Library Configuration so that only a limited number of randomly chosen links [from a particular category] are displayed?

    The idea is to put a shortcode on the main page so that a few random links are displayed as part of the content. They should be sorted by the ‘sortcode’ custom field so they appear in the correct order.

    Let’s say a 3×5 table is desired. It should then [very randomly] select fifteen links from the category, sort them by the ‘sortcode’ value, and then display the Name linked to the URL of each record in the 3×5 table. And each time the page is reloaded, a different set of fifteen links should appear.

    Is this currently doable?

    Regards,

    Fred

    The page I need help with: [log in to see the link]

Viewing 11 replies - 16 through 26 (of 26 total)
  • Plugin Author Yannick Lefebvre

    (@jackdewey)

    Fred, functions.php is a file in your theme, not in the plugin directory. You will need to copy that code only if you update your theme. To ever need to worry about it, you could create a child theme for your theme and put the code in there

    Thread Starter Fred Atkinson

    (@fatkinson)

    Yannick,

    In reading back, I discovered that the file I was looking for was in my theme’s directory.

    I guess I am good to go.

    Regards,

    Fred

    Thread Starter Fred Atkinson

    (@fatkinson)

    Thanks, Yannick,

    Thread Starter Fred Atkinson

    (@fatkinson)

    Hi, Yannick,

    Apparently I lost your code when my theme was updated. I noticed that it wasn’t sorting correctly when I looked at the table.

    So I pasted your code into the end of the functions.php file and uploaded it to my site.

    Problem corrected.

    I was toying with the idea of putting your code into a separate file and then using the ‘include’ function. Then I would only have to add three lines after a theme update. Like this:

    <?php
    include ‘sorting.php’;
    ?>

    Sorting would be the file I would paste your code into.

    Do you see any issues with that?

    Regards,

    Fred

    Plugin Author Yannick Lefebvre

    (@jackdewey)

    Hi Fred, Sorry, I should have been more explicit. Whenever you have custom code to put in your theme, you should create a child theme. A child theme inherits all of the files from a parent theme, but lets you add your own custom code elements in functions.php file that is separate from the parent theme functions.php. Just look up tutorials on how create a child theme and you’ll be update-proof.

    Thread Starter Fred Atkinson

    (@fatkinson)

    Plugin Author Yannick Lefebvre

    (@jackdewey)

    Yes, exactly!

    Thread Starter Fred Atkinson

    (@fatkinson)

    Yannick,

    I got as far as creating the ‘-child’ subirectory under themes and copying the style.css and functions.php files into the child theme directory.

    I am having trouble figuring out where to past the suggested coding into the functions.php file. The theme I am using uses the ‘get_stylesheet’ code.

    When I look at the Themes page back on my back end, it says that the child theme is incomplete.

    Any idea what I am overlooking?

    Regards,

    Fred

    Plugin Author Yannick Lefebvre

    (@jackdewey)

    Hi Fred, You should not be copying the style.css and functions.php into the child theme directory. As the instructions show, you should be creating a new file called style.css and putting a header similar to the one shown. Of course, you should change the Template for the name of the parent theme directory.

    Your functions.php file should also be a new empty file. This file will contain a bit of code to load the parent stylesheet, along with the few segments of custom code I gave you.. Perhaps this tutorial is better explained than the one you found: https://www.smashingmagazine.com/2016/01/create-customize-wordpress-child-theme/

    Thread Starter Fred Atkinson

    (@fatkinson)

    Hi, Yannick,

    Try as I might, I couldn’t make it work.

    So I cheated a bit.

    I installed a plugin called ‘Child Theme Configurator’.

    I created the child theme using it.

    Then, I pasted your code into the newly created functions.php which were complements of this plugin.

    Works like a champ.

    Cannot figure out what I did wrong.

    I deleted your code from the parent theme.

    I am running the child theme now. It is looking good. And the table is sorting correctly.

    Thanks for pointing me in the right direction.

    Regards,

    Fred

    • This reply was modified 3 years, 7 months ago by Fred Atkinson.
    Plugin Author Yannick Lefebvre

    (@jackdewey)

    Hi Fred, Glad you found a solution to be able to create a child theme. That’s actually an interesting plugin you found. I mentioned it to one of my friends who always asks me to help her create child themes.

Viewing 11 replies - 16 through 26 (of 26 total)
  • The topic ‘Custom Table’ is closed to new replies.