WordPress.org

Ready to get started?Download WordPress

Forums

Category link (with get_option) is not working (20 posts)

  1. alexwrld
    Member
    Posted 2 years ago #

    can anybody help me fix this.
    why is this link not taking me to the category destination?
    why is it showing blank in the page source?

    Here are the codes:

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

    </span>

  2. alexwrld
    Member
    Posted 2 years ago #

    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>

  3. Digital Raindrops
    Member
    Posted 2 years ago #

    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

  4. alexwrld
    Member
    Posted 2 years ago #

    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?

  5. alexwrld
    Member
    Posted 2 years ago #

    HI David!
    Are you around?
    I'm eager to hear from you...

  6. Big Bagel
    Member
    Posted 2 years ago #

    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.

  7. alexwrld
    Member
    Posted 2 years ago #

    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)

  8. Digital Raindrops
    Member
    Posted 2 years ago #

    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

  9. Digital Raindrops
    Member
    Posted 2 years ago #

    _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

  10. Big Bagel
    Member
    Posted 2 years ago #

    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.

  11. Digital Raindrops
    Member
    Posted 2 years ago #

    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'?

  12. alexwrld
    Member
    Posted 2 years ago #

    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: http://codex.wordpress.org/Forum_Welcome#Posting_Code ]

  13. alexwrld
    Member
    Posted 2 years ago #

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

  14. alexwrld
    Member
    Posted 2 years ago #

    Quite possible I'm nuts not following even the simplest suggestions :-(

  15. Digital Raindrops
    Member
    Posted 2 years ago #

    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

  16. Big Bagel
    Member
    Posted 2 years ago #

    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.

  17. alexwrld
    Member
    Posted 2 years ago #

    Thanks David!
    I hope you keep track of this thread. I am going to look into every bit of what you said.

    I'm so grateful to you and Big Bagel. Have great time :-)
    ALex

  18. alexwrld
    Member
    Posted 2 years ago #

    Thanks David!
    I hope you keep track of this thread. I am going to look into every bit of what you said.

    I'm so grateful to you and Big Bagel. Have great time :-)
    ALex

  19. alexwrld
    Member
    Posted 2 years ago #

    Thanks David!
    I hope you keep track of this thread. I am going to look into every bit of what you said.

    I'm so grateful to you and Big Bagel. Have great time :-)
    ALex

  20. Digital Raindrops
    Member
    Posted 2 years ago #

    lol three posts now that is indeed 'Deja Vu'?

Topic Closed

This topic has been closed to new replies.

About this Topic