Support » Developing with WordPress » Adding Link Buttons on pages(not posts)

  • juicyjuke

    (@juicyjuke)



    Hello, I’m building an information based wordpress site to assist beginner HVAC technicians with advanced electrical troubleshooting.

    I’m trying to find information on how to properly add link buttons on pages, but the only thing I can come up with is tutorials using plugins to add buttons to posts.

    There’s a good reason for this. For,instance I’m going to have 20-30 posts that contain step-by-step guides for every electrical part in each category they belong too.

    As it gets bigger, I don’t want them to have to scroll through 100s of posts to find the ones they need. I also cant have them use the search for various reasons. Instead I would like an alphabetical list of all the parts in the form of buttons.

    Maybe instead of running a query to list all posts, I can run a query to list post-title links in the form of buttons?

    I dont know where to start.

    Any suggestions ?

    • This topic was modified 7 months, 4 weeks ago by  bcworkz. Reason: not resolved
Viewing 5 replies - 1 through 5 (of 5 total)
  • juicyjuke

    (@juicyjuke)

    For example, instead of seeing a list of posts , and their features image when they enter a category, I would rather see an alphabetical list of post links in the form of buttons so they can just scroll down the ordered list of posts

    Example:
    Category : rooftop units

    Description: troubleshooting Electrical parts for rooftop package units

    Page content
    Scroll the alphabetical list for the parts you need information on

    Aon Controls
    Anvil Capacitors
    Anvil ignition boards
    Branch Operator Controls

    bloggingthemes

    (@bloggingthemes)

    IF I understand you correctly, you want to make text links into buttons? Will each page with the list of links (buttons) be from various categories or all from the same category?

    You could make your list of links to posts/pages using an unordered list. Then apply CSS styling to it as a global style like:

    Styles
    When you add custom styles like this, add them to the customizer’s Additional CSS tab.

    ul.mybuttons {
        margin-left: 0;
        padding-left: 0;
        list-style: none;
    }
    ul.mybuttons li a {
        background-color: #000;
        color: #fff;
        padding: 3px 12px;
        margin: 5px 0;
        display: inline-block;
        border-radius: 5px;
    }

    Your List

    <ul class="mybuttons">
     	<li><a href="#">Aon Controls</a></li>
     	<li><a href="#">Anvil Capacitors</a></li>
     	<li><a href="#">Anvil ignition boards</a></li>
     	<li><a href="#">Branch Operator Controls</a></li>
    </ul>

    Basically in your page, make a list, switch to the html view and add the class (whatever you decide to name it instead of my example “mybutton”) to the <ul> and then for each list item, use the editor to add a link. The # that you see as the links in my list example would simply be replaced with the actual links to the relative posts and pages.

    juicyjuke

    (@juicyjuke)

    Some pages will have 4 different categoroy posts but the categories will have posts from their category

    Thanks, I understand how to manually create buttons. What I’m trying to do is edit the query posts display posts as buttons so I dont have to manually go in myself and do it.

    If I can just figure out how to properly edit the

    Wp_Query

    To display the post title link in the form of a buttons. A real button. Then ill be happy

    Moderator bcworkz

    (@bcworkz)

    Hi juciyjuke,

    This topic is marked as resolved, but it doesn’t sound resolved. I’ll assume the resolved flag is in error and answer anyway 🙂

    You do not edit WP_Query class because it’s core code. If you really want a query to return only title and permalink, you’d have to write your own SQL query. The “fields” argument of WP_Query does not support the fields you want returned.

    It’s not that big a deal to have the query return all fields — you do not have to use all of them. What you want to do is edit the template responsible for output. Within the loop, instead of outputting title, date, content, categories, etc., simply output only the title/permalink that you want. You could output true HTML form buttons if you really want to, but I don’t see the point. It’s better to output anchor links and style them as buttons like bloggingthemes suggested.

    Moderator bcworkz

    (@bcworkz)

    OP has re-worded the original post, please continue at https://wordpress.org/support/topic/editing-wp_query-to-display-posts-as-buttons/

    Closing this topic.

    @juicyjuke – in the future, please do not start new topics to clarify problems you’ve discovered in the original post. Instead simply clarify within the same topic thread. We never delete topics unless they are clearly spam or abusive, so new topics make for a bit of a mess. I’ll let it go this time, but you need to stop handling such issues by starting a new topic. Thanks for understanding.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Adding Link Buttons on pages(not posts)’ is closed to new replies.