Viewing 15 replies - 1 through 15 (of 19 total)
  • Thread Starter alexwrld

    (@alexwrld)

    THis is the code:
    <span class=”catname”>
    <?php echo get_category_link(get_option(‘nt_cat2’));?>
    <?php echo get_cat_name(get_option(‘nt_cat2’)); ?>
    </span>

    Need the <a href="link">Text to Display</a>

    <span class="catname">
    <a href="<?php echo get_category_link(get_option('nt_cat2'));?>">
    <?php echo get_cat_name(get_option('nt_cat2')); ?></a>
    </span>

    HTH

    David

    Thread Starter alexwrld

    (@alexwrld)

    I was not posting code in the code box ??

    `<span class=”catname”>
    <a href=”<?php echo get_category_link(get_option(‘nt_cat2’));?>”>
    <?php echo get_cat_name(get_option(‘nt_cat2’)); ?></a>
    </span>

    Can you see something?

    Thread Starter alexwrld

    (@alexwrld)

    HI David!
    Are you around?
    I’m eager to hear from you…

    Is ‘nt_cat2’ something you or a theme/plugin has already added to the options database table? Was it properly populated with the ID of the category you’re trying to get a link for? Essentially, what exactly is being stored in ‘nt_cat2’?

    Explaining what you’re trying to display (The current post’s category info for example.) would be helpful. Right now, assuming that ‘nt_cat2’ is in the database and holds a category ID, there’s nothing wrong in the code.

    Thread Starter alexwrld

    (@alexwrld)

    I I have created a theme option page and nt is the short name of my theme.
    _cat2 is the id which gave the category. When I use this code, the link is not working (in the page source, I don’t see anything, it is showing blank)

    Hi Alex,
    As Big Bagel points out what is in option nt_cat2 and where is it set?

    The code should work providing that the ‘nt_cat2’ option has a number that relates to a category tag_ID

    David

    _cat2 is the id which gave the category

    Do you mean category or option id?

    For the theme option?
    id => $shortname .'_cat2',
    id => 'nt_cat2',
    id => '_cat2',

    David

    If you already know the category ID then it would be easier to do:

    <span class="catname">
    <a href="<?php echo get_category_link( 2 ); ?>">
    <?php echo get_cat_name( 2 ); ?></a>
    </span>

    Are you sure that your options page is properly saving that option into a database entry named nt_cat2?

    Edit:
    Bah, ninja posted again! ??
    Sorry for asking a similar question as David’s.

    Are you sure that your options page is properly saving that option into a database entry named nt_cat2?

    Quick Check:
    <?php echo 'Category 2 = ' .get_option('nt_cat2'); ?>

    These are case sensitive as well.

    HTH

    David

    @big Bagel ‘Deja Vu’?

    Thread Starter alexwrld

    (@alexwrld)

    Hi David!
    I am using the exact same code for the theme option:
    `id => $shortname .”_cat2″,
    id => “nt_cat2”,
    id => “_cat2”,

    [how to post code: https://codex.www.ads-software.com/Forum_Welcome#Posting_Code ]

    Thread Starter alexwrld

    (@alexwrld)

    Let me try once again. Thank you so very much for your time!

    Thread Starter alexwrld

    (@alexwrld)

    Quite possible I’m nuts not following even the simplest suggestions ??

    Do the Quick Check, or go to your WP Admin and change the URL
    yourwebsite/wp-admin/options.php

    And have a look at what is saved in nt_cat2, make sure it has a valid category ID.

    B.T.W.
    For an options page you should really be using serialized data, if you are saving more than one setting.

    David

    Do the Quick Check, or go to your WP Admin and change the URL
    yourwebsite/wp-admin/options.php

    Yup, best thing to check first would be that your stored option is in there correctly. Also, it’s probably not the problem, but it never hurts to mention it: whenever you directly change any files make sure to refresh any cache you’re using.

    @david

    /wp-admin/options.php

    …! I didn’t know that was there!
    All that time wasted sludging around phpmyadmin just to test things…

    ‘Deja Vu’?

    Indeed.

Viewing 15 replies - 1 through 15 (of 19 total)
  • The topic ‘Category link (with get_option) is not working’ is closed to new replies.